ts_datetime

Class to manipulate dates and times

Contents

Properties:

year   - Year
jday   - Julian Day (integer)
hour   - Hour
minute - Minute
second - Second
month  - Month (dependent on year and jday)
day    - Day of Month (dependent on year and jday)

Methods:

Constructor
    ts_datetime  - How now brown cow?
Modifiers:
    ceil         - Rounds up to the next    second, minute, hour or day
    floor        - Round down to the preceding "      "       "      "
    round        - Rounds to nearest           "      "       "      "
    modify       - String-based add/subtract time
Information:
    maketimeticks  - Return ticks and labels for a time axis
    toMatlabSerial - Return equivalent Matlab serial Date Number
Overloaded Matlab methods:
     eq     - implements '=='
     ge     - implements '>='
     gt     - implements '>'
     le     - implements '<='
     lt     - implements '<'
     ne     - implements '~='
     minus  - implements '-' (ts_datetime - ts_datetime = seconds
                              or ts_datetime - seconds = ts_datetime)
     plus   - implements '+' (ts_dateime + seconds = ts_datetime)
     max - Latest datetime
     min - Earliest datetime
Static methods
    ts_datetime.seconds2str    - Convert seconds to a string
    ts_datetime.str2seconds    - Convert a string to seconds
    ts_datetime.hastimesymbols - Determines if a string has time symbols

Example

format compact
dt1=ts_datetime(2007,04,05,12,00,00)
dt2=ts_datetime(2007,95,12,00,00)
dt3=ts_datetime('2007/04/05 12:00')
dt4=ts_datetime('2007/95 12:00')
dt1 = 
2007/04/05 12:00:00.000
dt2 = 
2007/04/05 12:00:00.000
dt3 = 
2007/04/05 12:00:00.000
dt4 = 
2007/04/05 12:00:00.000
dt1==dt2
dt2==dt3
dt3==dt4
ans =
     1
ans =
     1
ans =
     1
dt4-dt3
ans =
     0
dt4=dt4+86400
dt4-dt3
dt4 = 
2007/04/06 12:00:00.000
ans =
       86400
max(dt3,dt4)
ans = 
2007/04/06 12:00:00.000
min(dt3,dt4)
ans = 
2007/04/05 12:00:00.000
ts_datetime.str2seconds('3h')
ans =
       10800