123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869(*Does SQL allow us to insert using a float value?
New module for date type, represented as days since epoch?
As intervals of 24 hours starting from epoch + 1 second?
New module for time type, as seconds?
READ sql standard...literals.
*)moduleDate_time_extended=structincludeCore.Time(* 0123456789ABCDEFGHIJKLM*)(*MUST support alernate format with this example: 20190304000000 [-5:EST] *)letof_strings=tryof_stringswith_->(*try alternate format*)letyear_part=Core.String.slices04inletmonth_part=Core.String.slices46inletday_part=Core.String.slices68inlethour_part=Core.String.slices810inletminute_part=Core.String.slices1012inletseconds_part=Core.String.slices1214inlethours_offset_gmt=int_of_string(Core.String.slices1618)in(*can parse in format: %Y-%m-%dT%H:%M:%S.%s%Z and then some...*)letcomposed=Core.String.concat[year_part;"-";month_part;"-";day_part;"T";hour_part;":";minute_part;":";seconds_part]inletz=Core.Time.Zone.of_utc_offset~hours:hours_offset_gmtin(*of_string_gen ~default_zone:z ~find_zone:"new york" ~if_no_time_zone:(Use_this_one z) s*)of_string_gen~if_no_timezone:(`Use_this_onez)composedletshowt=to_string_abs~zone:(Core.Time.Zone.of_utc_offset~hours:(-5))t;;letto_yojsont=lets=showtinlets=Core.String.concat["{dt:";s;"}"]inYojson.Safe.from_strings;;letof_yojsonj=trylets=Yojson.Safe.to_stringjinletsplits=String.split_on_char':'sinletvalue_half=List.nthsplits1inletrbracket_i=String.indexvalue_half'}'inletvalue=String.subvalue_half0rbracket_iinlett=of_stringvalueinOktwith_err->Error"date_time_extended::of_yojson() failed.";;letequalt1t2=not(is_earliert1~than:t2)&¬(is_earliert2~than:t1)letcomparet1t2=ifis_earliert1~than:t2then1elseifis_earliert2~than:t1then-1else0(*Not useful unless have local hacked version of csvfields
let to_xml v =
[Csvfields.Xml.parse_string
(Core.String.concat [(to_string v)])]
let of_xml xml =
let sopt = Csvfields.Xml.contents xml in
match sopt with
| None -> raise (Failure "date_extended::of_xml() passed None as input")
| Some s -> of_string s
let xsd_format =
let open Csvfields.Xml.Restriction.Format in
`string
let xsd_restrictions = []
let xsd = [] *)end