duckling/Duckling/Duration
Steven Troxler 23ec021b07 Duration/RU: For non-int times, use the coarsest grain
Summary:
This commit fixes #111, which was an open issue that any non-integer
multiple of any unit of time was being converted to seconds.

My solution is to write a recursive function `Duration.Helpers.inCoarsestGrain`
which, given a grain `g` and double value `v` finds the coarses grain `g'` such that
`v * g` - rounded to the nearest seconds - has integral units.

We call this function only in the case of non-integer multiples, and we start our
search from the given grain because nothing coarser would make sense. The code could
actually be slightly more efficient if we started at the next-smallest grain, but
in the interest of clarity I think this is probably better.

Reviewed By: chessai

Differential Revision: D27891439

fbshipit-source-id: b048310963eb71337fd91ab4ef3c840134a76e73
2021-04-21 13:32:38 -07:00
..
AR Relicense to BSD3 2019-05-22 10:46:39 -07:00
BG Duration: Rename timesOneAndAHalf to nPlusOneHalf 2020-03-16 12:17:00 -07:00
DA Relicense to BSD3 2019-05-22 10:46:39 -07:00
DE adds frequent durations in German (#509) 2020-11-09 11:18:35 -08:00
EL Duration: Rename timesOneAndAHalf to nPlusOneHalf 2020-03-16 12:17:00 -07:00
EN Duration/EN: fix lint errors 2021-04-21 13:32:37 -07:00
ES Added new rule support composite duration phrase in ES (#498) 2020-06-25 09:47:32 -07:00
FR Relicense to BSD3 2019-05-22 10:46:39 -07:00
GA Relicense to BSD3 2019-05-22 10:46:39 -07:00
HE Relicense to BSD3 2019-05-22 10:46:39 -07:00
HI add: support for specific times in HI duration (#424) 2021-02-17 14:48:07 -08:00
HR Relicense to BSD3 2019-05-22 10:46:39 -07:00
HU Relicense to BSD3 2019-05-22 10:46:39 -07:00
IT Relicense to BSD3 2019-05-22 10:46:39 -07:00
JA Relicense to BSD3 2019-05-22 10:46:39 -07:00
KA Relicense to BSD3 2019-05-22 10:46:39 -07:00
KO Relicense to BSD3 2019-05-22 10:46:39 -07:00
MN Duration: Rename timesOneAndAHalf to nPlusOneHalf 2020-03-16 12:17:00 -07:00
NB Relicense to BSD3 2019-05-22 10:46:39 -07:00
NL NL/Duration: Support composite durations (#503) 2021-01-27 11:18:10 -08:00
PL Fix typo in PL Duration Rules (#426) 2020-12-14 16:32:05 -08:00
PT Relicense to BSD3 2019-05-22 10:46:39 -07:00
RO Relicense to BSD3 2019-05-22 10:46:39 -07:00
RU Duration/RU: For non-int times, use the coarsest grain 2021-04-21 13:32:38 -07:00
SV Relicense to BSD3 2019-05-22 10:46:39 -07:00
TR Time Dimension for TR locale (#584) 2021-04-06 10:32:18 -07:00
UK Duration: Rename timesOneAndAHalf to nPlusOneHalf 2020-03-16 12:17:00 -07:00
ZH Time&Duration/ZH: support Cantonese and more common expressions (#516-2) (#523) 2021-01-26 15:17:45 -08:00
Helpers.hs Duration/RU: For non-int times, use the coarsest grain 2021-04-21 13:32:38 -07:00
Rules.hs Relicense to BSD3 2019-05-22 10:46:39 -07:00
Types.hs Relicense to BSD3 2019-05-22 10:46:39 -07:00