package yocaml_syndication

  1. Overview
  2. Docs

Source file tz.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
(* YOCaml a static blog generator.
   Copyright (C) 2024 The Funkyworkers and The YOCaml's developers

   This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <https://www.gnu.org/licenses/>. *)

type t =
  | Ut
  | Gmt
  | Est
  | Edt
  | Cst
  | Cdt
  | Mst
  | Mdt
  | Pst
  | Pdt
  | Plus of int
  | Minus of int

let plus x = Plus x
let minus x = Minus x

let to_string = function
  | Ut -> "UT"
  | Gmt -> "GMT"
  | Est -> "EST"
  | Edt -> "EDT"
  | Cst -> "CST"
  | Cdt -> "CDT"
  | Mst -> "MST"
  | Mdt -> "MDT"
  | Pst -> "PST"
  | Pdt -> "PSDT"
  | Plus x -> Format.asprintf "+%04d" x
  | Minus x -> Format.asprintf "-%04d" x

let nb r =
  let s = Format.asprintf "%04d" r in
  Format.asprintf "%c%c:%c%c" s.[0] s.[1] s.[2] s.[3]

let to_string_rfc3339 = function
  | Ut | Gmt -> "Z"
  | Est -> "-05:00"
  | Edt -> "-04:00"
  | Cst -> "-06:00"
  | Cdt -> "-05:00"
  | Mst -> "-07:00"
  | Mdt -> "-06:00"
  | Pst -> "-08:00"
  | Pdt -> "-07:00"
  | Plus x -> "+" ^ nb x
  | Minus x -> "-" ^ nb x
OCaml

Innovation. Community. Security.