Commit 6465400e authored by Steffen Michels's avatar Steffen Michels

renamed 'dateTimeToTimestamp' to 'localDateTimeToTimestamp' (also the 'date'...

renamed 'dateTimeToTimestamp' to 'localDateTimeToTimestamp' (also the 'date' variant) & turned them into tasks; they are no pure functions as they depend on the local time zone
parent 7ee87429
......@@ -56,11 +56,42 @@ derive gText Date, Time, DateTime
derive gEditor Date, Time, DateTime
//Util
/*** Time & Date Conversion ***/
/**
* Converts a timestamp to UTC DateTime.
*
* @param Timestamp: The timestamp to convert.
*
* @return The resulting UTC DateTime
*/
timestampToGmDateTime :: !Timestamp -> DateTime
/**
* Converts a timestamp to local DateTime.
* This is a task, as the local time zone has to be detected.
*
* @param Timestamp: The timestamp to convert.
*
* @return The resulting local DateTime
*/
timestampToLocalDateTime :: !Timestamp -> Task DateTime
dateToTimestamp :: !Date -> Timestamp
datetimeToTimestamp :: !DateTime -> Timestamp
/**
* Converts a local Date to a timestamp.
* This is a task, as the local time zone has to be detected.
*
* @param Date: The date to convert
*
* @return The resulting timestamp
*/
localDateToTimestamp :: !Date -> Task Timestamp
/**
* Converts a local DateTime to a timestamp.
* This is a task, as the local time zone has to be detected.
*
* @param Date: The date & time to convert
*
* @return The resulting timestamp
*/
localDateTimeToTimestamp :: !DateTime -> Task Timestamp
/*** Special wait tasks ***/
......
......@@ -193,14 +193,17 @@ where
# (tm, world) = toLocalTime ts world
= (Ok (tmToDateTime tm), {iworld & world = world})
dateToTimestamp :: !Date -> Timestamp
dateToTimestamp {Date|day,mon,year}
= mkTime {Tm|sec = 0, min = 0, hour = 0, mday = day, mon = mon - 1, year = year - 1900, wday = 0, yday = 0, isdst = -1}
datetimeToTimestamp :: !DateTime -> Timestamp
datetimeToTimestamp {DateTime|day,mon,year,hour,min,sec}
= mkTime {Tm|sec = sec, min = min, hour = hour, mday = day, mon = mon - 1, year = year - 1900, wday = 0, yday = 0, isdst = -1}
localDateToTimestamp :: !Date -> Task Timestamp
localDateToTimestamp {Date|day,mon,year} = mkInstantTask localDateToTimestamp`
where
localDateToTimestamp` _ iworld =
(Ok (mkTime {Tm|sec = 0, min = 0, hour = 0, mday = day, mon = mon - 1, year = year - 1900, wday = 0, yday = 0, isdst = -1}), iworld)
localDateTimeToTimestamp :: !DateTime -> Task Timestamp
localDateTimeToTimestamp {DateTime|day,mon,year,hour,min,sec} = mkInstantTask localDateTimeToTimestamp`
where
localDateTimeToTimestamp` _ iworld =
(Ok (mkTime {Tm|sec = sec, min = min, hour = hour, mday = day, mon = mon - 1, year = year - 1900, wday = 0, yday = 0, isdst = -1}), iworld)
waitForTime :: !Time -> Task Time
waitForTime time =
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment