-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Description
The DatePrinter.from_fsrting function appears to work correctly with all possible formats.
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.
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.
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"
Metadata
Metadata
Assignees
Labels
No labels