Skip to content

Commit 0572bef

Browse files
add note about microsecond precision in Calendar.strftime
It was not obvious that the microsecond precision affects the formatting.
1 parent a0fb49f commit 0572bef

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

lib/elixir/lib/calendar.ex

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -496,33 +496,33 @@ defmodule Calendar do
496496
497497
The accepted formats for `string_format` are:
498498
499-
Format | Description | Examples (in ISO)
500-
:----- | :-----------------------------------------------------------------------| :------------------------
501-
a | Abbreviated name of day | Mon
502-
A | Full name of day | Monday
503-
b | Abbreviated month name | Jan
504-
B | Full month name | January
505-
c | Preferred date+time representation | 2018-10-17 12:34:56
506-
d | Day of the month | 01, 31
507-
f | Microseconds *(does not support width and padding modifiers)* | 000000, 999999, 0123
508-
H | Hour using a 24-hour clock | 00, 23
509-
I | Hour using a 12-hour clock | 01, 12
510-
j | Day of the year | 001, 366
511-
m | Month | 01, 12
512-
M | Minute | 00, 59
513-
p | "AM" or "PM" (noon is "PM", midnight as "AM") | AM, PM
514-
P | "am" or "pm" (noon is "pm", midnight as "am") | am, pm
515-
q | Quarter | 1, 2, 3, 4
516-
s | Number of seconds since the Epoch, 1970-01-01 00:00:00+0000 (UTC) | 1565888877
517-
S | Second | 00, 59, 60
518-
u | Day of the week | 1 (Monday), 7 (Sunday)
519-
x | Preferred date (without time) representation | 2018-10-17
520-
X | Preferred time (without date) representation | 12:34:56
521-
y | Year as 2-digits | 01, 01, 86, 18
522-
Y | Year | -0001, 0001, 1986
523-
z | +hhmm/-hhmm time zone offset from UTC (empty string if naive) | +0300, -0530
524-
Z | Time zone abbreviation (empty string if naive) | CET, BRST
525-
% | Literal "%" character | %
499+
Format | Description | Examples (in ISO)
500+
:----- | :-------------------------------------------------------------------------------------------------------- | :------------------------
501+
a | Abbreviated name of day | Mon
502+
A | Full name of day | Monday
503+
b | Abbreviated month name | Jan
504+
B | Full month name | January
505+
c | Preferred date+time representation | 2018-10-17 12:34:56
506+
d | Day of the month | 01, 31
507+
f | Microseconds (truncated to the microsecond precision, but *does not support width and padding modifiers*) | 000000, 999999, 0123
508+
H | Hour using a 24-hour clock | 00, 23
509+
I | Hour using a 12-hour clock | 01, 12
510+
j | Day of the year | 001, 366
511+
m | Month | 01, 12
512+
M | Minute | 00, 59
513+
p | "AM" or "PM" (noon is "PM", midnight as "AM") | AM, PM
514+
P | "am" or "pm" (noon is "pm", midnight as "am") | am, pm
515+
q | Quarter | 1, 2, 3, 4
516+
s | Number of seconds since the Epoch, 1970-01-01 00:00:00+0000 (UTC) | 1565888877
517+
S | Second | 00, 59, 60
518+
u | Day of the week | 1 (Monday), 7 (Sunday)
519+
x | Preferred date (without time) representation | 2018-10-17
520+
X | Preferred time (without date) representation | 12:34:56
521+
y | Year as 2-digits | 01, 01, 86, 18
522+
Y | Year | -0001, 0001, 1986
523+
z | +hhmm/-hhmm time zone offset from UTC (empty string if naive) | +0300, -0530
524+
Z | Time zone abbreviation (empty string if naive) | CET, BRST
525+
% | Literal "%" character | %
526526
527527
Any other character will be interpreted as an invalid format and raise an error.
528528

0 commit comments

Comments
 (0)