Hi, I have some regional climate model data that is dated by "days since 1949-12-1". None of the models use a Gregorian calendar (365/366 days/year depending on leap year). They either use a "365-day" calendar (no Feb 29 in any year) or "360-day" calendar (every month is exactly 30 days).
I found two functions in the Financial Toolbox that can generate the number of days between two dates, based on either a 365- or 360-day calendar (days365 and days360, respectively).
But I need to do the reverse. I have the number of days since a point in time, and I need the dates. I'm currently using "caldays", but it doesn't appear to have the calendar type as an option. This is the code I'm currently using, before I discovered the usage of different calendars:
var_time = importdata('var_time.txt');base_date = datetime(1949,12,1);% round 'time' attribute to nearest integer, add the number of days it
% represents to the baseline date, then extract the month and year from
% the new date generated
data_mx = day(base_date+caldays(floor(var_time))); % day of month
data_mx(:,2) = month(base_date+caldays(floor(var_time))); % month number
data_mx(:,3) = year(base_date+caldays(floor(var_time))); % year
% results in 365 days ending with 12/30/1952, a leap year
% should exclude 2/29/1952 and end with 12/31/1952
Anyone know of any Matlab functions I'm missing, or coding ideas to accomplish this?
Thanks.
UPDATE: I've added a new file: var_time_mx.txt which includes data from the beginning of the dataset (1/1/1950) through 1956, so it includes two leap years (1952 and 1956). Details about it are in the comment thread with @Walter Robertson, below.
Best Answer