Browse thread
.-
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Alexander Fuchs <alexander.fuchs@e...> |
| Subject: | Re: [Caml-list] .- |
Anastasia Gornostaeva wrote:
> open Unix
>
> let _ =
> let curr_time = time () in
> let curr_tm = gmtime curr_time in
> let new_time, _ = mktime {curr_tm with tm_hour = curr_tm.tm_hour+1} in
> let diff = new_time -. curr_time in
> Printf.printf "%f\n%f\n%f\n"
> curr_time
> new_time
> diff
>
>
> gives an negative result -7200.000000. Why?
Form the manual:
gmtime : Assumes UTC (Coordinated Universal Time), also known as GMT.
mktime : The tm argument is interpreted in the local time zone.
So, actually you compare GMT with your local time zone, which in my case
(Germany) returns 0 for the above example.
Try localtime instead of gmtime:
localtime : Assumes the local time zone.
Alex