Update date and time of day function names to iso8601 instead of rfc3339

This commit is contained in:
Lily Rose 2025-07-08 20:30:55 +10:00
parent 85f3e35224
commit 73e2c1bd3e
3 changed files with 8 additions and 8 deletions

View file

@ -1515,7 +1515,7 @@ pub type ServerStatus {
fn server_status_decoder() -> Decoder(ServerStatus) { fn server_status_decoder() -> Decoder(ServerStatus) {
use status <- decode.field("status", decode.string) use status <- decode.field("status", decode.string)
use version <- decode.field("version", 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 description <- decode.field("description", decode.string)
use stats <- decode.field("stats", stats_decoder()) use stats <- decode.field("stats", stats_decoder())
use health <- decode.field("health", health_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( use reset_date <- decode.optional_field(
"reset_date", "reset_date",
option.None, option.None,
decode.optional(time.rfc3339_date_decoder()), decode.optional(time.iso8601_date_decoder()),
) )
use issued_at_int <- decode.field("iat", decode.int) use issued_at_int <- decode.field("iat", decode.int)
let issued_at = timestamp.from_unix_seconds(issued_at_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) let bytes = bit_array.from_string(input)
use #(year, bytes) <- result.try(parse_year(from: bytes)) use #(year, bytes) <- result.try(parse_year(from: bytes))
use bytes <- result.try(accept_byte(from: bytes, value: byte_minus)) 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:)) 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) use value <- decode.then(decode.string)
case parse_rfc3339_date(value) { case parse_iso8601_date(value) {
Ok(date) -> decode.success(date) Ok(date) -> decode.success(date)
Error(Nil) -> decode.failure(Date(1970, January, 1), "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) let bytes = bit_array.from_string(input)
use #(hours, bytes) <- result.try(parse_hours(from: bytes)) use #(hours, bytes) <- result.try(parse_hours(from: bytes))
use bytes <- result.try(accept_byte(from: bytes, value: byte_colon)) 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:)) 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) 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) Ok(date) -> decode.success(date)
Error(Nil) -> decode.failure(TimeOfDay(0, 0, 0, 0), "TimeOfDay") Error(Nil) -> decode.failure(TimeOfDay(0, 0, 0, 0), "TimeOfDay")
} }