Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CalendarPrinter.from_fstring cannot actually parse most formats #35

Open
dmbaturin opened this issue Nov 17, 2020 · 0 comments
Open

CalendarPrinter.from_fstring cannot actually parse most formats #35

dmbaturin opened this issue Nov 17, 2020 · 0 comments

Comments

@dmbaturin
Copy link

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"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant