Open dmbaturin opened 3 years ago
The DatePrinter.from_fsrting function appears to work correctly with all possible formats.
DatePrinter.from_fsrting
utop # CalendarLib.Printer.DatePrinter.from_fstring "%Y-%m-%d %H:%M%z" "1970-01-01 00:00+0000" |> CalendarLib.Printer.DatePrinter.sprint "%d/%m/%Y" ;; - : string = "01/01/1970"
If you want to handle both date and time, however... The CalendarPrinter.from_fstring function fails with a generic exception for most formats.
CalendarPrinter.from_fstring
utop # CalendarLib.Printer.CalendarPrinter.from_fstring "%Y-%m-%d %H:%M%z" "1970-01-01 00:00+0000" |> CalendarLib.Printer.CalendarPrinter.sprint "%d/%m/%Y" ;; Exception: Invalid_argument "Cannot create the calendar".
It only seems to works for shortcut format specifiers that include both date and time, like %c.
%c
utop # CalendarLib.Printer.CalendarPrinter.from_fstring "%c" "Thu Sep 18 14:10:51 2003" |> CalendarLib.Printer.CalendarPrinter.sprint "%d/%m/%Y" ;; - : string = "18/09/2003"
The
DatePrinter.from_fsrting
function appears to work correctly with all possible formats.If you want to handle both date and time, however... The
CalendarPrinter.from_fstring
function fails with a generic exception for most formats.It only seems to works for shortcut format specifiers that include both date and time, like
%c
.