+2
-2
manifest.toml
+2
-2
manifest.toml
···
2
2
# You typically do not need to edit this file
3
3
4
4
packages = [
5
-
{ name = "gleam_stdlib", version = "0.36.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "C0D14D807FEC6F8A08A7C9EF8DFDE6AE5C10E40E21325B2B29365965D82EB3D4" },
6
-
{ name = "gleeunit", version = "1.0.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "D364C87AFEB26BDB4FB8A5ABDE67D635DC9FA52D6AB68416044C35B096C6882D" },
5
+
{ name = "gleam_stdlib", version = "0.37.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "5398BD6C2ABA17338F676F42F404B9B7BABE1C8DC7380031ACB05BBE1BCF3742" },
6
+
{ name = "gleeunit", version = "1.1.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "72CDC3D3F719478F26C4E2C5FED3E657AC81EC14A47D2D2DEBB8693CA3220C3B" },
7
7
{ name = "ranger", version = "1.2.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "ranger", source = "hex", outer_checksum = "1566C272B1D141B3BBA38B25CB761EF56E312E79EC0E2DFD4D3C19FB0CC1F98C" },
8
8
]
9
9
+43
-5
src/birl.gleam
+43
-5
src/birl.gleam
···
984
984
pub fn weekday(value: Time) -> Weekday {
985
985
case value {
986
986
Time(wall_time: t, offset: o, timezone: _, monotonic_time: _) -> {
987
-
let assert Ok(weekday) = list.at(weekdays, ffi_weekday(t, o))
987
+
let assert Ok(weekday) = weekday_from_int(ffi_weekday(t, o))
988
988
weekday
989
989
}
990
990
}
···
1016
1016
1017
1017
pub fn month(value: Time) -> Month {
1018
1018
let #(#(_, month, _), _, _) = to_parts(value)
1019
-
let assert Ok(month) = list.at(months, month - 1)
1019
+
let assert Ok(month) = month_from_int(month)
1020
1020
month
1021
1021
}
1022
1022
···
1451
1451
}
1452
1452
1453
1453
@target(erlang)
1454
-
const weekdays = [Mon, Tue, Wed, Thu, Fri, Sat, Sun]
1454
+
fn weekday_from_int(weekday: Int) -> Result(Weekday, Nil) {
1455
+
case weekday {
1456
+
0 -> Ok(Mon)
1457
+
1 -> Ok(Tue)
1458
+
2 -> Ok(Wed)
1459
+
3 -> Ok(Thu)
1460
+
4 -> Ok(Fri)
1461
+
5 -> Ok(Sat)
1462
+
6 -> Ok(Sun)
1463
+
_ -> Error(Nil)
1464
+
}
1465
+
}
1455
1466
1456
1467
@target(javascript)
1457
-
const weekdays = [Sun, Mon, Tue, Wed, Thu, Fri, Sat]
1468
+
fn weekday_from_int(weekday: Int) -> Result(Weekday, Nil) {
1469
+
case weekday {
1470
+
0 -> Ok(Sun)
1471
+
1 -> Ok(Mon)
1472
+
2 -> Ok(Tue)
1473
+
3 -> Ok(Wed)
1474
+
4 -> Ok(Thu)
1475
+
5 -> Ok(Fri)
1476
+
6 -> Ok(Sat)
1477
+
_ -> Error(Nil)
1478
+
}
1479
+
}
1458
1480
1459
-
const months = [Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec]
1481
+
fn month_from_int(month: Int) -> Result(Month, Nil) {
1482
+
case month {
1483
+
1 -> Ok(Jan)
1484
+
2 -> Ok(Feb)
1485
+
3 -> Ok(Mar)
1486
+
4 -> Ok(Apr)
1487
+
5 -> Ok(May)
1488
+
6 -> Ok(Jun)
1489
+
7 -> Ok(Jul)
1490
+
8 -> Ok(Aug)
1491
+
9 -> Ok(Sep)
1492
+
10 -> Ok(Oct)
1493
+
11 -> Ok(Nov)
1494
+
12 -> Ok(Dec)
1495
+
_ -> Error(Nil)
1496
+
}
1497
+
}
1460
1498
1461
1499
const weekday_strings = [
1462
1500
#(Mon, #("Monday", "Mon")),
+1
-6
src/birl/duration.gleam
+1
-6
src/birl/duration.gleam
···
1
1
import gleam/int
2
-
import gleam/bool
3
2
import gleam/list
4
3
import gleam/order
5
4
import gleam/regex
···
258
257
]
259
258
260
259
fn inner_blur(values: List(#(Int, Unit))) -> #(Int, Unit) {
261
-
let assert Ok(second) = list.at(values, 0)
262
-
let leading = list.at(values, 1)
263
-
use <- bool.guard(result.is_error(leading), second)
264
-
let assert [leading] = result.values([leading])
265
-
260
+
let assert [second, leading, ..] = values
266
261
let assert Ok(leading_unit) = list.key_find(unit_values, leading.1)
267
262
let assert Ok(second_unit) = list.key_find(unit_values, second.1)
268
263