Commit a3dafe05 authored by Mart Lubbers's avatar Mart Lubbers

Merge branch...

Merge branch '170-add-pure-datetime-to-timestamp-conversion-without-time-zone-conversion' into 'master'

adapted to non-pure 'mkTime' & added conversion functions for UTC DateTime to Timestamp

Closes #170

See merge request !89
parents 1ef5f3ae 8c0516be
......@@ -228,7 +228,7 @@ determineAppPath world
= (currentDirectory </> (fst o hd o sortBy cmpFileTime) (zip2 batchfiles infos), world)
where
cmpFileTime (_,Ok {FileInfo | lastModifiedTime = x})
(_,Ok {FileInfo | lastModifiedTime = y}) = mkTime x > mkTime y
(_,Ok {FileInfo | lastModifiedTime = y}) = timeGm x > timeGm y
//By default, we use the modification time of the applaction executable as version id
determineAppVersion :: !FilePath!*World -> (!String,!*World)
......
......@@ -92,6 +92,22 @@ localDateToTimestamp :: !Date -> Task Timestamp
* @return The resulting timestamp
*/
localDateTimeToTimestamp :: !DateTime -> Task Timestamp
/**
* Converts a UTC Date to a timestamp.
*
* @param Date: The date to convert
*
* @return The resulting timestamp
*/
utcDateToTimestamp :: !Date -> Timestamp
/**
* Converts a UTC DateTime to a timestamp.
*
* @param Date: The date & time to convert
*
* @return The resulting timestamp
*/
utcDateTimeToTimestamp :: !DateTime -> Timestamp
/*** Special wait tasks ***/
......
......@@ -196,14 +196,24 @@ where
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)
localDateToTimestamp` _ iworld=:{world}
# (ts, world) = mkTime {Tm|sec = 0, min = 0, hour = 0, mday = day, mon = mon - 1, year = year - 1900, wday = 0, yday = 0, isdst = -1} world
= (Ok ts, {iworld & world = world})
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)
localDateTimeToTimestamp` _ iworld=:{world}
# (ts, world) = mkTime {Tm|sec = sec, min = min, hour = hour, mday = day, mon = mon - 1, year = year - 1900, wday = 0, yday = 0, isdst = -1} world
= (Ok ts, {iworld & world = world})
utcDateToTimestamp :: !Date -> Timestamp
utcDateToTimestamp {Date|day,mon,year} =
timeGm {Tm|sec = 0, min = 0, hour = 0, mday = day, mon = mon - 1, year = year - 1900, wday = 0, yday = 0, isdst = -1}
utcDateTimeToTimestamp :: !DateTime -> Timestamp
utcDateTimeToTimestamp {DateTime|day,mon,year,hour,min,sec} =
timeGm {Tm|sec = sec, min = min, hour = hour, mday = day, mon = mon - 1, year = year - 1900, wday = 0, yday = 0, isdst = -1}
waitForTime :: !Time -> Task Time
waitForTime time =
......
......@@ -108,7 +108,7 @@ determineAppPath world
= (currentDirectory </> (fst o hd o sortBy cmpFileTime) (zip2 batchfiles infos), world)
where
cmpFileTime (_,Ok {FileInfo | lastModifiedTime = x})
(_,Ok {FileInfo | lastModifiedTime = y}) = mkTime x > mkTime y
(_,Ok {FileInfo | lastModifiedTime = y}) = timeGm x > timeGm y
destroyIWorld :: !*IWorld -> *World
destroyIWorld iworld=:{IWorld|world} = world
......
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