Compare commits

...

2 commits

Author SHA1 Message Date
7f5a308f83 Bump version to 1.6.1
Some checks are pending
test / test (push) Waiting to run
2025-07-08 20:31:06 +10:00
73e2c1bd3e Update date and time of day function names to iso8601 instead of rfc3339 2025-07-08 20:30:55 +10:00
4 changed files with 9 additions and 9 deletions

View file

@ -1,5 +1,5 @@
name = "spacetraders_sdk"
version = "1.6.0"
version = "1.6.1"
gleam = ">= 1.11.0"
description = "A Gleam SDK for the spacetraders.io game API"
licences = ["MIT"]

View file

@ -1515,7 +1515,7 @@ pub type ServerStatus {
fn server_status_decoder() -> Decoder(ServerStatus) {
use status <- decode.field("status", decode.string)
use version <- decode.field("version", decode.string)
use reset_date <- decode.field("resetDate", time.rfc3339_date_decoder())
use reset_date <- decode.field("resetDate", time.iso8601_date_decoder())
use description <- decode.field("description", decode.string)
use stats <- decode.field("stats", stats_decoder())
use health <- decode.field("health", health_decoder())

View file

@ -91,7 +91,7 @@ fn jwt_payload_decoder() -> Decoder(JwtPayload) {
use reset_date <- decode.optional_field(
"reset_date",
option.None,
decode.optional(time.rfc3339_date_decoder()),
decode.optional(time.iso8601_date_decoder()),
)
use issued_at_int <- decode.field("iat", decode.int)
let issued_at = timestamp.from_unix_seconds(issued_at_int)

View file

@ -16,7 +16,7 @@ pub fn rfc3339_timestamp_decoder() -> Decoder(Timestamp) {
}
}
pub fn parse_rfc3339_date(input: String) -> Result(Date, Nil) {
pub fn parse_iso8601_date(input: String) -> Result(Date, Nil) {
let bytes = bit_array.from_string(input)
use #(year, bytes) <- result.try(parse_year(from: bytes))
use bytes <- result.try(accept_byte(from: bytes, value: byte_minus))
@ -27,15 +27,15 @@ pub fn parse_rfc3339_date(input: String) -> Result(Date, Nil) {
Ok(Date(year:, month:, day:))
}
pub fn rfc3339_date_decoder() -> Decoder(Date) {
pub fn iso8601_date_decoder() -> Decoder(Date) {
use value <- decode.then(decode.string)
case parse_rfc3339_date(value) {
case parse_iso8601_date(value) {
Ok(date) -> decode.success(date)
Error(Nil) -> decode.failure(Date(1970, January, 1), "Date")
}
}
pub fn parse_rfc3339_time_of_day(input: String) -> Result(TimeOfDay, Nil) {
pub fn parse_iso8601_time_of_day(input: String) -> Result(TimeOfDay, Nil) {
let bytes = bit_array.from_string(input)
use #(hours, bytes) <- result.try(parse_hours(from: bytes))
use bytes <- result.try(accept_byte(from: bytes, value: byte_colon))
@ -49,9 +49,9 @@ pub fn parse_rfc3339_time_of_day(input: String) -> Result(TimeOfDay, Nil) {
Ok(TimeOfDay(hours:, minutes:, seconds:, nanoseconds:))
}
pub fn rfc3339_time_of_day_decoder() -> Decoder(TimeOfDay) {
pub fn iso8601_time_of_day_decoder() -> Decoder(TimeOfDay) {
use value <- decode.then(decode.string)
case parse_rfc3339_time_of_day(value) {
case parse_iso8601_time_of_day(value) {
Ok(date) -> decode.success(date)
Error(Nil) -> decode.failure(TimeOfDay(0, 0, 0, 0), "TimeOfDay")
}