Skip to content

Commit

Permalink
bug fixes, formatting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
massivefermion committed Jun 2, 2024
1 parent 17b48be commit 52d6757
Show file tree
Hide file tree
Showing 9 changed files with 194 additions and 406 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: erlef/setup-beam@v1
with:
otp-version: '26'
gleam-version: '1.1'
gleam-version: '1.2'

- run: |
version="v$(cat gleam.toml | grep -m 1 "version" | sed -r "s/version *= *\"([[:digit:].]+)\"/\1/")"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- uses: erlef/setup-beam@v1
with:
otp-version: '26'
gleam-version: '1.1'
gleam-version: '1.2'
rebar3-version: '3'
- run: gleam test
- run: gleam format --check src test
4 changes: 2 additions & 2 deletions gleam.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name = "birl"
version = "1.7.0"
version = "1.7.1"

description = "Date / Time handling for Gleam"
gleam = ">= 0.32.0"
Expand All @@ -10,7 +10,7 @@ links = [{ title = "Gleam", href = "https://gleam.run" }]

[dependencies]
ranger = "~> 1.2"
gleam_stdlib = "~> 0.37 or ~> 1.0"
gleam_stdlib = "~> 0.38 or ~> 1.0"

[dev-dependencies]
gleeunit = "~> 1.1"
4 changes: 2 additions & 2 deletions manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
# You typically do not need to edit this file

packages = [
{ name = "gleam_stdlib", version = "0.37.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "5398BD6C2ABA17338F676F42F404B9B7BABE1C8DC7380031ACB05BBE1BCF3742" },
{ name = "gleam_stdlib", version = "0.38.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "663CF11861179AF415A625307447775C09404E752FF99A24E2057C835319F1BE" },
{ name = "gleeunit", version = "1.1.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "72CDC3D3F719478F26C4E2C5FED3E657AC81EC14A47D2D2DEBB8693CA3220C3B" },
{ name = "ranger", version = "1.2.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "ranger", source = "hex", outer_checksum = "1566C272B1D141B3BBA38B25CB761EF56E312E79EC0E2DFD4D3C19FB0CC1F98C" },
]

[requirements]
gleam_stdlib = { version = "~> 0.37 or ~> 1.0" }
gleam_stdlib = { version = "~> 0.38 or ~> 1.0" }
gleeunit = { version = "~> 1.1" }
ranger = { version = "~> 1.2" }
54 changes: 20 additions & 34 deletions src/birl.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,8 @@ pub fn parse(value: String) -> Result(Time, Nil) {
Ok(#(time_string, Ok(0)))
}
[time_string, milli_seconds_string], [_]
| [_], [time_string, milli_seconds_string] -> {
| [_], [time_string, milli_seconds_string]
-> {
Ok(#(
time_string,
milli_seconds_string
Expand Down Expand Up @@ -427,7 +428,8 @@ pub fn parse_time_of_day(value: String) -> Result(#(TimeOfDay, String), Nil) {
Ok(#(time_string, Ok(0)))
}
[time_string, milli_seconds_string], [_]
| [_], [time_string, milli_seconds_string] -> {
| [_], [time_string, milli_seconds_string]
-> {
Ok(#(
time_string,
milli_seconds_string
Expand Down Expand Up @@ -475,7 +477,8 @@ pub fn parse_naive_time_of_day(
Ok(#(time_string, Ok(0)))
}
[time_string, milli_seconds_string], [_]
| [_], [time_string, milli_seconds_string] -> {
| [_], [time_string, milli_seconds_string]
-> {
Ok(#(
time_string,
milli_seconds_string
Expand Down Expand Up @@ -590,7 +593,8 @@ pub fn from_naive(value: String) -> Result(Time, Nil) {
[_], [_] -> Ok(#(time_string, Ok(0)))

[time_string, milli_seconds_string], [_]
| [_], [time_string, milli_seconds_string] ->
| [_], [time_string, milli_seconds_string]
->
Ok(#(
time_string,
milli_seconds_string
Expand Down Expand Up @@ -895,12 +899,8 @@ pub fn difference(a: Time, b: Time) -> duration.Duration {
}

const string_to_units = [
#("year", duration.Year),
#("month", duration.Month),
#("week", duration.Week),
#("day", duration.Day),
#("hour", duration.Hour),
#("minute", duration.Minute),
#("year", duration.Year), #("month", duration.Month), #("week", duration.Week),
#("day", duration.Day), #("hour", duration.Hour), #("minute", duration.Minute),
#("second", duration.Second),
]

Expand Down Expand Up @@ -947,12 +947,8 @@ pub fn parse_relative(origin: Time, legible_difference: String) {
}

const units_to_string = [
#(duration.Year, "year"),
#(duration.Month, "month"),
#(duration.Week, "week"),
#(duration.Day, "day"),
#(duration.Hour, "hour"),
#(duration.Minute, "minute"),
#(duration.Year, "year"), #(duration.Month, "month"), #(duration.Week, "week"),
#(duration.Day, "day"), #(duration.Hour, "hour"), #(duration.Minute, "minute"),
#(duration.Second, "second"),
]

Expand Down Expand Up @@ -1594,28 +1590,18 @@ fn month_from_int(month: Int) -> Result(Month, Nil) {
}

const weekday_strings = [
#(Mon, #("Monday", "Mon")),
#(Tue, #("Tuesday", "Tue")),
#(Wed, #("Wednesday", "Wed")),
#(Thu, #("Thursday", "Thu")),
#(Fri, #("Friday", "Fri")),
#(Sat, #("Saturday", "Sat")),
#(Mon, #("Monday", "Mon")), #(Tue, #("Tuesday", "Tue")),
#(Wed, #("Wednesday", "Wed")), #(Thu, #("Thursday", "Thu")),
#(Fri, #("Friday", "Fri")), #(Sat, #("Saturday", "Sat")),
#(Sun, #("Sunday", "Sun")),
]

const month_strings = [
#(Jan, #("January", "Jan")),
#(Feb, #("February", "Feb")),
#(Mar, #("March", "Mar")),
#(Apr, #("April", "Apr")),
#(May, #("May", "May")),
#(Jun, #("June", "Jun")),
#(Jul, #("July", "Jul")),
#(Aug, #("August", "Aug")),
#(Sep, #("September", "Sep")),
#(Oct, #("October", "Oct")),
#(Nov, #("November", "Nov")),
#(Dec, #("December", "Dec")),
#(Jan, #("January", "Jan")), #(Feb, #("February", "Feb")),
#(Mar, #("March", "Mar")), #(Apr, #("April", "Apr")), #(May, #("May", "May")),
#(Jun, #("June", "Jun")), #(Jul, #("July", "Jul")), #(Aug, #("August", "Aug")),
#(Sep, #("September", "Sep")), #(Oct, #("October", "Oct")),
#(Nov, #("November", "Nov")), #(Dec, #("December", "Dec")),
]

@external(erlang, "birl_ffi", "now")
Expand Down
21 changes: 5 additions & 16 deletions src/birl/duration.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -245,14 +245,8 @@ const accurate_month = 2_629_746_000_000
const accurate_year = 31_556_952_000_000

const unit_values = [
#(Year, year),
#(Month, month),
#(Week, week),
#(Day, day),
#(Hour, hour),
#(Minute, minute),
#(Second, second),
#(MilliSecond, milli_second),
#(Year, year), #(Month, month), #(Week, week), #(Day, day), #(Hour, hour),
#(Minute, minute), #(Second, second), #(MilliSecond, milli_second),
#(MicroSecond, 1),
]

Expand Down Expand Up @@ -292,14 +286,9 @@ const milli_second_units = [
]

const units = [
#(Year, year_units),
#(Month, month_units),
#(Week, week_units),
#(Day, day_units),
#(Hour, hour_units),
#(Minute, minute_units),
#(Second, second_units),
#(MilliSecond, milli_second_units),
#(Year, year_units), #(Month, month_units), #(Week, week_units),
#(Day, day_units), #(Hour, hour_units), #(Minute, minute_units),
#(Second, second_units), #(MilliSecond, milli_second_units),
]

/// you can use this function to create a new duration using expressions like:
Expand Down
Loading

0 comments on commit 52d6757

Please sign in to comment.