Module ts_datetime

Function Index

add_datetime_and_duration/2 addition is done in a "natural" way, e.g.: DateTime = 2005-01-01 00:00:00 and Duration = 1 day -> range = [2005-01-01 00:00:00, 2005-01-01 23:59:59] i.e.
add_days/2
add_hours/2
add_minutes/2
add_seconds/2
add_weeks/2
datetime_to_type/3 Convert DateTime between various time representations Timezone is currently unsupported and should when supported, only be used when Type = floating Note : This code expects DateTime to contain a legal date and time value, so no skipped - transition to DST hour or non-existing leap days.
datetime_to_usec/3 converts date_time time to a universal format (gregorian seconds in UTC format), Type is ONLY used to determine which time to use when DateTime ends a DST period - use 'start' if the DateTime is the first time in a range and 'end' if it is the end of a time range Note : {pseudo_usec, Time} is returned when a non-existent time in a date-time is supplied, this occurs only when a floating time is changed to DST, e.g.
diff_datetime/4 get difference between DT1 and DT2 ~ abs(DT1 - DT2), for a certain time unit (supplied by Freq) Note : worst ordo = days_in_range/2 ordo.
dtstart_lt_dtend/3 ensure that dtstart < dtend in a time_switch__cond_x record().
ge_datetime/3 determine if DT1 >= DT2.
gt_datetime/3 determine if DT1 > DT2.
le_datetime/3 determine if DT1 =< DT2.
sub_days/2
unsafe_add_months/2 needed for adding longer periods.
unsafe_add_years/2 needed for adding longer periods.

Function Details

add_datetime_and_duration/2

add_datetime_and_duration(DateTime, Duration) -> #date_time{}

addition is done in a "natural" way, e.g.: DateTime = 2005-01-01 00:00:00 and Duration = 1 day -> range = [2005-01-01 00:00:00, 2005-01-01 23:59:59] i.e. the range consists of 60 * 60 * 24 seconds (1 day) - leap seconds and DST are ignored, so that the range end will always be the same, independent of the actual number of passed seconds. Note that each second counts as a range of Duration = 1 second, rather than a point in time, this implies: DateTime = 2005-01-01 00:00:00 and Duration = 1 second -> range = [2005-01-01 00:00:00, 2005-01-01 00:00:00] Note : duration record() don't handle years and month so the date part of a date can never become illegal, but the time part may become so due to change to DST

add_days/2

add_days() -> term()

add_hours/2

add_hours() -> term()

add_minutes/2

add_minutes() -> term()

add_seconds/2

add_seconds() -> term()

add_weeks/2

add_weeks() -> term()

datetime_to_type/3

datetime_to_type(DateTime, Type, Timezone) -> #date_time{}

Convert DateTime between various time representations Timezone is currently unsupported and should when supported, only be used when Type = floating Note : This code expects DateTime to contain a legal date and time value, so no skipped - transition to DST hour or non-existing leap days

datetime_to_usec/3

datetime_to_usec(Type, Timezone, Date_time::DateTime) -> integer() | {pseudo_usec, Time}

converts date_time time to a universal format (gregorian seconds in UTC format), Type is ONLY used to determine which time to use when DateTime ends a DST period - use 'start' if the DateTime is the first time in a range and 'end' if it is the end of a time range Note : {pseudo_usec, Time} is returned when a non-existent time in a date-time is supplied, this occurs only when a floating time is changed to DST, e.g. a 02:xx:xx value is set to 03:00:00 (assuming DST change occurs at 02:00:00). Note : "If neither "tzid" nor "tzurl" [Timezone] are present, all non-UTC times within this time switch should be interpreted as being "floating" times, i.e., that they are specified in the local time-zone of the CPL server." - RFC 3880 chapter 4.4 p15 * tzid and tzurl are currently unsupported

diff_datetime/4

diff_datetime(Timezone, DT1v::DT1, DT2v::DT2, Freq) -> integer()

get difference between DT1 and DT2 ~ abs(DT1 - DT2), for a certain time unit (supplied by Freq) Note : worst ordo = days_in_range/2 ordo

dtstart_lt_dtend/3

dtstart_lt_dtend(Timezone, S, E) -> true | false

ensure that dtstart < dtend in a time_switch__cond_x record(). E and S are assumed to have valid date and time values, they may only be invalid due to transition to DST Note : see cpl/README about date-time format limitations, in regard to floating date-time values without time-zone settings.

ge_datetime/3

ge_datetime(Timezone, DT1, DT2) -> true | false

determine if DT1 >= DT2

gt_datetime/3

gt_datetime(Timezone, DT1, DT2) -> true | false

determine if DT1 > DT2

le_datetime/3

le_datetime(Timezone, DT1, DT2) -> true | false

determine if DT1 =< DT2

sub_days/2

sub_days() -> term()

unsafe_add_months/2

unsafe_add_months(Date_time::DT, Month) -> #date_time{}

returns: values may be illegal i.e. 2005-03-31 + 1 month -> 2005-04-31

needed for adding longer periods

unsafe_add_years/2

unsafe_add_years(Date_time::DT, Year) -> #date_time{}

returns: values may be illegal i.e. 2005-03-31 + 1 month -> 2005-04-31

needed for adding longer periods


Generated by EDoc, Oct 17 2007, 16:48:06.