diff options
author | Sébastien Dailly <sebastien@chimrod.com> | 2017-01-01 15:49:42 +0100 |
---|---|---|
committer | Sébastien Dailly <sebastien@chimrod.com> | 2017-01-01 15:49:42 +0100 |
commit | 444c0baa87b6edfb21c002bf9e079e10509ee0e9 (patch) | |
tree | 08b4978fd53941a2bb4d5931b5bd8c45e40ccf5b /tools.ml | |
parent | 023c11470e32744a43b7e3c7c248f3c47ebdc687 (diff) |
Switched dates 0 to 1899/12/30
Diffstat (limited to 'tools.ml')
-rwxr-xr-x | tools.ml | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -268,19 +268,21 @@ module Date = struct + day + b + 1720995 -(* + 2415019 (* Shift to 30/12/1899 *) *) + - 2415019 (* Shift to 30/12/1899 *) |> Num.num_of_int end let date_from_julian_day day = begin + let shift_day = Num.floor_num day + |> Num.add_num (Num.num_of_int 2415019) in - let z = Num.int_of_num (Num.floor_num day) in + let z = Num.int_of_num shift_day in let f = if z >= 2299161 then (* We use the Num module here to prevent overflow *) - let day' = Num.(((num_of_int 4) */ day +/ (num_of_int 274277)) // (num_of_int 146097)) + let day' = Num.(((num_of_int 4) */ shift_day +/ (num_of_int 274277)) // (num_of_int 146097)) |> Num.floor_num |> Num.int_of_num in z + 1401 + ((day' * 3) / 4) - 38 |