@@ -10,7 +10,7 @@ import gleam/string
1010import gleam/time/duration . { type Duration }
1111import gleam/time/timestamp
1212import simplifile
13- import tzif/tzparser
13+ import tzif/parser
1414
1515/// Time Zone Database record. This is typically created by
1616/// loading from the operating system with the `load_from_os`
@@ -20,7 +20,7 @@ import tzif/tzparser
2020pub opaque type TzDatabase {
2121 TzDatabase (
2222 zone_names : List ( String ) ,
23- zone_data : dict . Dict ( String , tzparser . TzFile ) ,
23+ zone_data : dict . Dict ( String , parser . TzFile ) ,
2424 )
2525}
2626
@@ -82,7 +82,7 @@ pub fn new() -> TzDatabase {
8282pub fn add_tzfile (
8383 db : TzDatabase ,
8484 zone_name : String ,
85- tzfile : tzparser . TzFile ,
85+ tzfile : parser . TzFile ,
8686) -> TzDatabase {
8787 let namelist = case dict . has_key ( db . zone_data , zone_name ) {
8888 True -> db . zone_names
@@ -94,7 +94,7 @@ pub fn add_tzfile(
9494fn process_tzfile (
9595 filename : String ,
9696 components_to_drop : Int ,
97- ) -> Result ( # ( String , tzparser . TzFile ) , Nil ) {
97+ ) -> Result ( # ( String , parser . TzFile ) , Nil ) {
9898 let zone_name =
9999 filepath . split ( filename )
100100 |> list . drop ( components_to_drop )
@@ -103,9 +103,7 @@ fn process_tzfile(
103103 use tzdata <- result . try (
104104 simplifile . read_bits ( filename ) |> result . replace_error ( Nil ) ,
105105 )
106- use timeinfo <- result . try (
107- tzparser . parse ( tzdata ) |> result . replace_error ( Nil ) ,
108- )
106+ use timeinfo <- result . try ( parser . parse ( tzdata ) |> result . replace_error ( Nil ) )
109107
110108 Ok ( # ( zone_name , timeinfo ) )
111109}
@@ -117,12 +115,10 @@ pub fn get_available_timezones(db: TzDatabase) -> List(String) {
117115}
118116
119117/// Time zone parameters record.
120- /// - `offset` is the offset from UTC.
118+ /// - `offset` is the offset from UTC using [gleam_time](https://hexdocs.pm/gleam_time/gleam/time/duration.html#Duration)
119+ /// `Duration`.
121120/// - `is_dst` indicates if it is daylight savings time
122121/// - `designation` is the time zone designation
123- /// This is the same information provided by a `TtInfo` record, but
124- /// modified to use the [gleam_time](https://hexdocs.pm/gleam_time/index.html)
125- /// duration type and a boolean for the daylight saving time indication.
126122pub type ZoneParameters {
127123 ZoneParameters ( offset : Duration , is_dst : Bool , designation : String )
128124}
@@ -223,7 +219,7 @@ type TtSlice {
223219}
224220
225221// Turn time zone fields into a list of timezone information slices
226- fn create_slices ( fields : tzparser . TzFileFields ) -> List ( TtSlice ) {
222+ fn create_slices ( fields : parser . TzFileFields ) -> List ( TtSlice ) {
227223 let infos =
228224 list . zip ( fields . ttinfos , fields . designations )
229225 |> list . index_map ( fn ( tup , idx ) { # ( idx , tup ) } )
@@ -246,7 +242,7 @@ fn create_slices(fields: tzparser.TzFileFields) -> List(TtSlice) {
246242 |> result . values
247243}
248244
249- fn default_slice ( fields : tzparser . TzFileFields ) -> Result ( TtSlice , Nil ) {
245+ fn default_slice ( fields : parser . TzFileFields ) -> Result ( TtSlice , Nil ) {
250246 use ttinfo <- result . try ( list . first ( fields . ttinfos ) )
251247 use designation <- result . try ( list . first ( fields . designations ) )
252248 let isdst = case ttinfo . isdst {
0 commit comments