Skip to content

Commit ddd082a

Browse files
committed
v1.6.0
1 parent ea56978 commit ddd082a

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Changelog
22

3-
## Unreleased
3+
## v1.6.0 - 2025-11-18
44

55
- Fixed a bug where the `duration.to_iso8601_string` returned an invalid value
66
for a duration of `0` seconds.

gleam.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name = "gleam_time"
2-
version = "1.5.0"
2+
version = "1.6.0"
33
description = "Work with time in Gleam!"
44
gleam = ">= 1.11.0"
55
licences = ["Apache-2.0"]

manifest.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ packages = [
66
{ name = "filepath", version = "1.1.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "filepath", source = "hex", outer_checksum = "B06A9AF0BF10E51401D64B98E4B627F1D2E48C154967DA7AF4D0914780A6D40A" },
77
{ name = "gleam_bitwise", version = "1.3.1", build_tools = ["gleam"], requirements = [], otp_app = "gleam_bitwise", source = "hex", outer_checksum = "B36E1D3188D7F594C7FD4F43D0D2CE17561DE896202017548578B16FE1FE9EFC" },
88
{ name = "gleam_regexp", version = "1.1.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_regexp", source = "hex", outer_checksum = "9C215C6CA84A5B35BB934A9B61A9A306EC743153BE2B0425A0D032E477B062A9" },
9-
{ name = "gleam_stdlib", version = "0.61.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "3DC407D6EDA98FCE089150C11F3AD892B6F4C3CA77C87A97BAE8D5AB5E41F331" },
9+
{ name = "gleam_stdlib", version = "0.65.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "7C69C71D8C493AE11A5184828A77110EB05A7786EBF8B25B36A72F879C3EE107" },
1010
{ name = "gleam_yielder", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_yielder", source = "hex", outer_checksum = "8E4E4ECFA7982859F430C57F549200C7749823C106759F4A19A78AEA6687717A" },
11-
{ name = "gleeunit", version = "1.6.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "63022D81C12C17B7F1A60E029964E830A4CBD846BBC6740004FC1F1031AE0326" },
11+
{ name = "gleeunit", version = "1.9.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "DA9553CE58B67924B3C631F96FE3370C49EB6D6DC6B384EC4862CC4AAA718F3C" },
1212
{ name = "prng", version = "4.0.1", build_tools = ["gleam"], requirements = ["gleam_bitwise", "gleam_stdlib", "gleam_yielder"], otp_app = "prng", source = "hex", outer_checksum = "695AB70E4BE713042062E901975FC08D1EC725B85B808D4786A14C406ADFBCF1" },
13-
{ name = "qcheck", version = "1.0.0", build_tools = ["gleam"], requirements = ["exception", "gleam_regexp", "gleam_stdlib", "gleam_yielder", "prng"], otp_app = "qcheck", source = "hex", outer_checksum = "6DAE7925E350480CE813F80D07AC4B9BAB25360F0D63EC98C5742D8456C9A9A1" },
14-
{ name = "simplifile", version = "2.3.0", build_tools = ["gleam"], requirements = ["filepath", "gleam_stdlib"], otp_app = "simplifile", source = "hex", outer_checksum = "0A868DAC6063D9E983477981839810DC2E553285AB4588B87E3E9C96A7FB4CB4" },
13+
{ name = "qcheck", version = "1.0.2", build_tools = ["gleam"], requirements = ["exception", "gleam_regexp", "gleam_stdlib", "gleam_yielder", "prng"], otp_app = "qcheck", source = "hex", outer_checksum = "88BF97FD7E52E49B339D8768FA32B86648B92EF56F923A84EBD6A7B0BCD39852" },
14+
{ name = "simplifile", version = "2.3.1", build_tools = ["gleam"], requirements = ["filepath", "gleam_stdlib"], otp_app = "simplifile", source = "hex", outer_checksum = "957E0E5B75927659F1D2A1B7B75D7B9BA96FAA8D0C53EA71C4AD9CD0C6B848F6" },
1515
]
1616

1717
[requirements]

src/gleam/time/duration.gleam

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import gleam/bool
12
import gleam/int
23
import gleam/order
34
import gleam/string
@@ -189,6 +190,7 @@ pub fn add(left: Duration, right: Duration) -> Duration {
189190
/// [1]: https://en.wikipedia.org/wiki/ISO_8601#Durations
190191
///
191192
pub fn to_iso8601_string(duration: Duration) -> String {
193+
use <- bool.guard(duration == empty, "PT0S")
192194
let split = fn(total, limit) {
193195
let amount = total % limit
194196
let remainder = { total - amount } / limit
@@ -210,11 +212,10 @@ pub fn to_iso8601_string(duration: Duration) -> String {
210212
|> string.append("T")
211213
|> add(hours, "H")
212214
|> add(minutes, "M")
213-
case output, seconds, duration.nanoseconds {
214-
"PT", 0, 0 -> output <> "0S"
215-
_, 0, 0 -> output
216-
_, _, 0 -> output <> int.to_string(seconds) <> "S"
217-
_, _, _ -> {
215+
case seconds, duration.nanoseconds {
216+
0, 0 -> output
217+
_, 0 -> output <> int.to_string(seconds) <> "S"
218+
_, _ -> {
218219
let f = nanosecond_digits(duration.nanoseconds, 0, "")
219220
output <> int.to_string(seconds) <> "." <> f <> "S"
220221
}

0 commit comments

Comments
 (0)