@colisweb/rescript-toolkit 4.26.2 → 4.26.3

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@colisweb/rescript-toolkit",
3
- "version": "4.26.2",
3
+ "version": "4.26.3",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "clean": "rescript clean",
@@ -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
  }