scruffy/common
Small types shared across several Scryfall object types.
Types
Values
pub fn date_schema() -> glon.JsonSchema(Int)
A schema for Scryfall’s "YYYY-MM-DD" date strings, decoded into a Unix
timestamp representing midnight UTC on that date.
Several Scryfall entities (cards, sets, rulings, migrations, preview
info) currently model timestamps as Int “for now”, so this keeps that
contract without pulling in a date/time library.
pub fn date_to_unix_seconds(date: String) -> Result(Int, Nil)
Parses a "YYYY-MM-DD" date string into a Unix timestamp in seconds
(midnight UTC on that date), using the proleptic Gregorian calendar.
Only valid for years on or after 1 CE; that covers every date Scryfall has ever returned.
pub fn datetime_schema() -> glon.JsonSchema(Int)
A schema for RFC 3339 datetime strings such as
"2026-08-31T21:01:56.902+00:00" (or with a trailing "Z"), decoded
into a Unix timestamp in seconds. Fractional seconds are truncated.
Scryfall’s Bulk Data objects currently model updated_at this way “for
now”, matching the Int-timestamp treatment date_schema gives plain
dates elsewhere in the API.
pub fn datetime_to_unix_seconds(
datetime: String,
) -> Result(Int, Nil)
Parses an RFC 3339 datetime string into a Unix timestamp in seconds.
pub fn uri_schema() -> glon.JsonSchema(uri.Uri)
A schema for URI strings, decoded via gleam/uri.parse.
Scryfall guarantees every URI it returns is well-formed, so a value that fails to parse indicates a breaking change upstream and is treated as a decode-time bug rather than a recoverable error.
pub fn uuid_schema() -> glon.JsonSchema(String)
A schema for UUID strings, decoded as-is.