This is a post to the Ocaml mailing list. I reproduce it here, in case the information can be useful more in general.
I need to convert a time, expressed in yyyy/mm/dd hh:mm:ss form, into a floating point.
The conversion has to be done in GMT, but the real point is, the conversion must NOT change due to daylight savings time.
Ocaml seems to have only one conversion function, however: Unix.mktime, which takes a time, and makes a float in the local time zone.
No problem, I thought: I will simply add 3600 if the conversion result tells me that dst is active (and then convert for the difference between GMT and winter time).
NO! This does not work! Look at the two conversions below. The tmrec differs by one hour.
However, the two floating point numbers returned are identical, and tm_isdst is set to true in both cases!
This means that I have no way of using the standard libraries to convert a time expressed in yyyy/mm/ss hh:mm:ss to a float!
This is a basic operation, and it is a big let down that there is no such library function in Ocaml.
I will have to write it from basic principles.
Anybody has a better suggestion?