diff --git a/gleam.toml b/gleam.toml index 2be2621..e3760d9 100644 --- a/gleam.toml +++ b/gleam.toml @@ -18,8 +18,8 @@ gleam_stdlib = "~> 0.36 or ~> 1.0" lustre = "~> 4.1" lustre_ssg = "~> 0.5.0" gleam_javascript = "~> 0.8" -ranged_int = "~> 1.0" -bigi = "~> 2.1" +ranged_int = "~> 2.0" +bigi = "~> 3.0" [dev-dependencies] gleeunit = "~> 1.0" diff --git a/manifest.toml b/manifest.toml index 0b1a0ae..e7340e8 100644 --- a/manifest.toml +++ b/manifest.toml @@ -2,7 +2,7 @@ # You typically do not need to edit this file packages = [ - { name = "bigi", version = "2.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "bigi", source = "hex", outer_checksum = "B6F7CAF319F13F32DB4331A750534912A9AEE1C195DD8E5DA83A42A4AD390274" }, + { name = "bigi", version = "3.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "bigi", source = "hex", outer_checksum = "FFDFC542A5146C535AE09AB9A642D652AD8B018509CDA70E1D09741EDB64FBF7" }, { name = "filepath", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "filepath", source = "hex", outer_checksum = "EFB6FF65C98B2A16378ABC3EE2B14124168C0CE5201553DE652E2644DCFDB594" }, { name = "gleam_erlang", version = "0.25.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_erlang", source = "hex", outer_checksum = "054D571A7092D2A9727B3E5D183B7507DAB0DA41556EC9133606F09C15497373" }, { name = "gleam_javascript", version = "0.8.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_javascript", source = "hex", outer_checksum = "14D5B7E1A70681E0776BF0A0357F575B822167960C844D3D3FA114D3A75F05A8" }, @@ -13,17 +13,17 @@ packages = [ { name = "jot", version = "0.3.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "jot", source = "hex", outer_checksum = "574A2DACA106E9B4826C9F3F2D3911844C7826D554C08E404696CC16F85E0392" }, { name = "lustre", version = "4.1.5", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_json", "gleam_otp", "gleam_stdlib"], otp_app = "lustre", source = "hex", outer_checksum = "C90B3DC868D346C49E98C8A62F2E594AE559D5FF25A46269D60FAA5939FCE827" }, { name = "lustre_ssg", version = "0.5.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "jot", "lustre", "simplifile", "tom"], otp_app = "lustre_ssg", source = "hex", outer_checksum = "F208FC79C25AE70976AEA2BA4262760BCC5C807E637742FEF66F0692150039C6" }, - { name = "ranged_int", version = "1.0.0", build_tools = ["gleam"], requirements = ["bigi", "gleam_stdlib"], otp_app = "ranged_int", source = "hex", outer_checksum = "8AACD49213E87BC6E7CE5F80038C1989966CF8187382760B6168E5EA9F364B09" }, + { name = "ranged_int", version = "2.0.0", build_tools = ["gleam"], requirements = ["bigi", "gleam_stdlib"], otp_app = "ranged_int", source = "hex", outer_checksum = "9FCDA804C1884015FC25F3F8BE429FC450D402F861B5C561464479F5B1162A41" }, { name = "simplifile", version = "1.7.0", build_tools = ["gleam"], requirements = ["filepath", "gleam_stdlib"], otp_app = "simplifile", source = "hex", outer_checksum = "1D5DFA3A2F9319EC85825F6ED88B8E449F381B0D55A62F5E61424E748E7DDEB0" }, { name = "thoas", version = "0.4.1", build_tools = ["rebar3"], requirements = [], otp_app = "thoas", source = "hex", outer_checksum = "4918D50026C073C4AB1388437132C77A6F6F7C8AC43C60C13758CC0ADCE2134E" }, { name = "tom", version = "0.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "tom", source = "hex", outer_checksum = "0831C73E45405A2153091226BF98FB485ED16376988602CC01A5FD086B82D577" }, ] [requirements] -bigi = { version = "~> 2.1" } +bigi = { version = "~> 3.0" } gleam_javascript = { version = "~> 0.8" } gleam_stdlib = { version = "~> 0.36 or ~> 1.0" } gleeunit = { version = "~> 1.0" } lustre = { version = "~> 4.1" } lustre_ssg = { version = "~> 0.5.0" } -ranged_int = { version = "~> 1.0" } +ranged_int = { version = "~> 2.0" } diff --git a/src/gloss/utils/date.gleam b/src/gloss/utils/date.gleam index 4fa1042..9df18a3 100644 --- a/src/gloss/utils/date.gleam +++ b/src/gloss/utils/date.gleam @@ -1,5 +1,5 @@ import gleam/bool -import gleam/order.{type Order, Gt, Lt} +import gleam/order.{type Order, Eq} import gleam/int import gleam/string import gloss/utils/ints/day.{type Day} @@ -86,16 +86,14 @@ pub fn is_valid_date(date: Date) -> Bool { /// Compare if `a` is before (lower than) `b`. pub fn compare(a: Date, b: Date) -> Order { - case a.year, b.year { - a_year, b_year if a_year < b_year -> Lt - a_year, b_year if a_year > b_year -> Gt - _, _ -> { - case month_to_int(a.month), month_to_int(b.month) { - a_int, b_int if a_int < b_int -> Lt - a_int, b_int if a_int > b_int -> Gt - _, _ -> day.compare(a.day, b.day) + case int.compare(a.year, b.year) { + order.Eq -> { + case int.compare(month_to_int(a.month), month_to_int(b.month)) { + order.Eq -> day.compare(a.day, b.day) + other -> other } } + other -> other } }