Skip to content

Commit 4afa2fc

Browse files
committed
Time: + basic format
1 parent 1c0d1ec commit 4afa2fc

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

time.ml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,20 @@ let format_date8hms =
131131
put_2d s 12 t.tm_sec;
132132
Bytes.unsafe_to_string s
133133

134+
(** YYYY-MM-DD hh:mm:ss *)
135+
let format_date8hms =
136+
let template = "2019-__-__ __:__:__" in
137+
fun t ->
138+
let open Unix in
139+
let s = Bytes.of_string template in
140+
replace_year_2019 s (t.tm_year + 1900);
141+
put_2d s 5 (t.tm_mon+1);
142+
put_2d s 8 t.tm_mday;
143+
put_2d s 11 t.tm_hour;
144+
put_2d s 14 t.tm_min;
145+
put_2d s 17 t.tm_sec;
146+
Bytes.unsafe_to_string s
147+
134148
(** MMDD *)
135149
let format_date4 t =
136150
let open Unix in
@@ -154,6 +168,9 @@ let date8hm_string = format_date8hm $ Unix.localtime
154168
let date8hms_gmt_string = format_date8hms $ Unix.gmtime
155169
let date8hms_string = format_date8hms $ Unix.localtime
156170

171+
let basic_gmt_string = format_basic $ Unix.gmtime
172+
let basic_string = format_basic $ Unix.localtime
173+
157174
let date4_gmt_string = format_date4 $ Unix.gmtime
158175
let date4_string = format_date4 $ Unix.localtime
159176

0 commit comments

Comments
 (0)