Skip to content

Commit

Permalink
Attempt to fix daylight saving time offset.
Browse files Browse the repository at this point in the history
  • Loading branch information
sagotch committed Mar 4, 2015
1 parent 50cee2f commit 43cc89b
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions src/ISO8601_lexer.mll
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
{


let int = int_of_string

(* Date helpers *)
let mkdate y m d =
let local = fst (Unix.mktime {
Unix.tm_sec = 0 ;
tm_min = 0 ;
tm_hour = 0 ;
tm_mday = d ;
tm_mon = m - 1 ;
tm_year = y - 1900 ;
tm_wday = -1 ;
tm_yday = -1 ;
tm_isdst = false ; }) in
let (t, tm) = Unix.mktime {
Unix.tm_sec = 0 ;
tm_min = 0 ;
tm_hour = 0 ;
tm_mday = d ;
tm_mon = m - 1 ;
tm_year = y - 1900 ;
tm_wday = -1 ;
tm_yday = -1 ;
tm_isdst = false ; } in
let offset = fst (Unix.mktime (Unix.gmtime 0. )) in
local -. offset
(** FIXME: Ensure the daylight saving time correction is right. *)
t -. offset +. (if tm.tm_isdst then 3600. else 0.)

let ymd y m d = mkdate (int y) (int m) (int d)
let ym y m = mkdate (int y) (int m) 1
Expand Down

0 comments on commit 43cc89b

Please sign in to comment.