Skip to content

Commit c07b450

Browse files
committed
Merge branch 'feature/timezone-ord-schema' into 'master'
Make timezones comparable See merge request routine/timmy!20
2 parents 54ce31b + 99908b6 commit c07b450

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

timmy/lib/src/timezone.ml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,12 @@ let name = function
4242
"it appears you mixed a pre 1.0 Clock implementation with a post 1.1 \
4343
Timmy interface"
4444
| { name; _ } -> name
45+
46+
module T = struct
47+
type nonrec t = t
48+
49+
let compare t1 t2 = String.compare (name t1) (name t2)
50+
let sexp_of_t t = Base.Sexp.Atom (name t)
51+
end
52+
53+
include Base.Comparable.Make (T)

timmy/lib/src/timezone.mli

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,10 @@ val gmt_offset_seconds_at_time : t -> Ptime.t -> int
4343

4444
(** [name tz] is the IANA name of [tz], if it could be determined. *)
4545
val name : t -> string
46+
47+
(** {1 Comparison} *)
48+
49+
(** Timezones are comparable through their names. *)
50+
51+
(** @inline *)
52+
include Base.Comparable.S with type t := t

0 commit comments

Comments
 (0)