Skip to content

Commit

Permalink
Merge pull request #46 from dinkelspiel/update-stdlib
Browse files Browse the repository at this point in the history
chore: update stdlib from 0.44 to 0.48 and ranger to require >= 1.4.0
  • Loading branch information
massivefermion authored Dec 18, 2024
2 parents b1b8f14 + 57ef8c4 commit f8a5158
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 31 deletions.
2 changes: 1 addition & 1 deletion gleam.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ repository = { type = "github", user = "massivefermion", repo = "birl" }
links = [{ title = "Gleam", href = "https://gleam.run" }]

[dependencies]
ranger = ">= 1.2.0 and < 2.0.0"
ranger = ">= 1.4.0 and < 2.0.0"
gleam_stdlib = ">= 0.44.0 and < 2.0.0"
gleam_regexp = ">= 1.0.0 and < 2.0.0"

Expand Down
5 changes: 3 additions & 2 deletions manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@

packages = [
{ name = "gleam_regexp", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_regexp", source = "hex", outer_checksum = "A3655FDD288571E90EE9C4009B719FEF59FA16AFCDF3952A76A125AF23CF1592" },
{ name = "gleam_stdlib", version = "0.44.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "A6E55E309A6778206AAD4038D9C49E15DF71027A1DB13C6ADA06BFDB6CF1260E" },
{ name = "gleam_stdlib", version = "0.48.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "6C7799F315EB3AC53271078685297579183A287F2E65C6DD36C6583C76F12BBE" },
{ name = "gleam_yielder", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_yielder", source = "hex", outer_checksum = "8E4E4ECFA7982859F430C57F549200C7749823C106759F4A19A78AEA6687717A" },
{ name = "gleeunit", version = "1.2.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "F7A7228925D3EE7D0813C922E062BFD6D7E9310F0BEE585D3A42F3307E3CFD13" },
{ name = "ranger", version = "1.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "ranger", source = "hex", outer_checksum = "B8F3AFF23A3A5B5D9526B8D18E7C43A7DFD3902B151B97EC65397FE29192B695" },
{ name = "ranger", version = "1.4.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "gleam_yielder"], otp_app = "ranger", source = "hex", outer_checksum = "C8988E8F8CDBD3E7F4D8F2E663EF76490390899C2B2885A6432E942495B3E854" },
]

[requirements]
Expand Down
50 changes: 22 additions & 28 deletions src/birl.gleam
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import birl/duration
import birl/zones
import gleam/bool
import gleam/function
import gleam/int
import gleam/iterator
import gleam/list
import gleam/option
import gleam/order
import gleam/regexp
import gleam/result
import gleam/string
import gleam/yielder
import birl/duration
import birl/zones

import ranger

Expand Down Expand Up @@ -270,31 +268,31 @@ pub fn to_iso8601(value: Time) -> String {
}

/// if you need to parse an `ISO8601` string, this is probably what you're looking for.
///
///
/// given the huge surface area that `ISO8601` covers, it does not make sense for `birl`
/// to support all of it in one function, so this function parses only strings for which both
/// day and time of day can be extracted or deduced. Some acceptable examples are given below:
///
///
/// - `2019t14-4` -> `2019-01-01T14:00:00.000-04:00`
///
///
/// - `2019-03-26t14:00.9z` -> `2019-03-26T14:00:00.900Z`
///
///
/// - `2019-03-26+330` -> `2019-03-26T00:00:00.000+03:30`
///
///
/// - `20190326t1400-4` -> `2019-03-26T14:00:00.000-04:00`
///
///
/// - `19051222T16:38-3` -> `1905-12-22T16:38:00.000-03:00`
///
///
/// - `2019-03-26 14:30:00.9Z` -> `2019-03-26T14:30:00.900Z`
///
///
/// - `2019-03-26T14:00:00.9Z` -> `2019-03-26T14:00:00.900Z`
///
///
/// - `1905-12-22 16:38:23-3` -> `1905-12-22T16:38:23.000-03:00`
///
///
/// - `2019-03-26T14:00:00,4999Z` -> `2019-03-26T14:00:00.499Z`
///
///
/// - `1905-12-22T163823+0330` -> `1905-12-22T16:38:23.000+03:30`
///
///
/// - `1905-12-22T16:38:23.000+03:30` -> `1905-12-22T16:38:23.000+03:30`
pub fn parse(value: String) -> Result(Time, Nil) {
let assert Ok(offset_pattern) = regexp.from_string("(.*)([+|\\-].*)")
Expand Down Expand Up @@ -391,17 +389,17 @@ pub fn parse(value: String) -> Result(Time, Nil) {
/// in the string. Some acceptable examples are given below:
///
/// - `t25z` -> `#(TimeOfDay(2, 5, 0, 0), "Z")`
///
///
/// - `14-4` -> `#(TimeOfDay(14, 0, 0, 0), "-04:00")`
///
///
/// - `T145+4` -> `#(TimeOfDay(14, 5, 0, 0), "+04:00")`
///
///
/// - `16:38-3` -> `#(TimeOfDay(16, 38, 0, 0), "-03:00")`
///
///
/// - `t14:65.9z` -> `#(TimeOfDay(14, 6, 5, 900), "-04:00")`
///
///
/// - `163823+0330` -> `#(TimeOfDay(16, 38, 23, 0), "+03:30")`
///
///
/// - `T16:38:23.050+03:30` -> `#(TimeOfDay(16, 38, 23, 50), "+03:30")`
pub fn parse_time_of_day(value: String) -> Result(#(TimeOfDay, String), Nil) {
let assert Ok(offset_pattern) = regexp.from_string("(.*)([+|\\-].*)")
Expand Down Expand Up @@ -917,7 +915,7 @@ const string_to_units = [
]

/// you could say this is the opposite of `legible_difference`
///
///
/// ```gleam
/// > parse_relative(birl.now(), "8 minutes ago")
/// ```
Expand Down Expand Up @@ -1149,11 +1147,7 @@ pub fn short_string_month(value: Time) -> String {
/// can be used to create a time range starting from time `a` with step `s`
///
/// if `b` is `option.None` the range will be infinite
pub fn range(
from a: Time,
to b: option.Option(Time),
step s: duration.Duration,
) -> yielder.Yielder(Time) {
pub fn range(from a: Time, to b: option.Option(Time), step s: duration.Duration) {
let assert Ok(range) = case b {
option.Some(b) ->
ranger.create(
Expand Down

0 comments on commit f8a5158

Please sign in to comment.