@colisweb/rescript-toolkit 4.26.2 → 4.26.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,6 +10,7 @@ and translation = {
10
10
 
11
11
  let availableLanguagesToString: availableLanguages => string
12
12
  let availableLanguagesFromString: string => availableLanguages
13
+ let getDateFnsLocale: availableLanguages => DateFns.dateFnsLocale
13
14
 
14
15
  module type IntlConfig = {
15
16
  let messages: messages
@@ -28,8 +29,6 @@ module Make: (Config: IntlConfig) =>
28
29
  let useCurrentLocale: unit => availableLanguages
29
30
  let setCurrentLocale: availableLanguages => unit
30
31
 
31
- let getDateFnsLocale: availableLanguages => DateFns.dateFnsLocale
32
-
33
32
  module Provider: {
34
33
  @react.component
35
34
  let make: (~children: React.element) => React.element
@@ -124,11 +124,20 @@ module Time = {
124
124
  duration.minutes,
125
125
  duration.seconds,
126
126
  ) {
127
- | (None, None, None, Some(h), Some(min), None) =>
128
- let min = min->Int.toString
129
- `${h->Int.toString} : ${min->String.length === 1 ? "0" ++ min : min}`
130
- | (None, None, None, Some(h), None, None) => `${h->Int.toString} h`
131
- | (None, None, None, None, Some(min), None) => `${min->Int.toString} min`
127
+ | (None, None, None, Some(h), Some(min), sec) =>
128
+ let secondsAsMinutesRounded = sec->Option.mapWithDefault(0, sec => sec > 30 ? 1 : 0)
129
+ let minRounded =
130
+ (min + secondsAsMinutesRounded === 60 ? 0 : min + secondsAsMinutesRounded)->Int.toString
131
+ let hRounded = min + secondsAsMinutesRounded === 60 ? h + 1 : h
132
+
133
+ `${hRounded->Int.toString} : ${minRounded->String.length === 1
134
+ ? "0" ++ minRounded
135
+ : minRounded}`
136
+ | (None, None, None, Some(h), None, _) => `${h->Int.toString} h`
137
+ | (None, None, None, None, Some(min), sec) =>
138
+ let secondsAsMinutesRounded = sec->Option.mapWithDefault(0, sec => sec > 30 ? 1 : 0)
139
+ `${(min + secondsAsMinutesRounded)->Int.toString} min`
140
+ | (None, None, None, None, None, Some(sec)) => `${sec->Int.toString} sec`
132
141
  | _ => DateFns.formatDuration(duration)
133
142
  }
134
143
  }