Calendar: add support for ISO8601 basic format#6005
Conversation
There was a problem hiding this comment.
No need for the format_mfa indirection. We also don't wrap terms in error messages in Elixir with backticks. Please write the message as:
raise ArgumentError, "DateTime.to_iso8601/2 expects format to be :extended or :basic, got: #{inspect fotmat}"
|
Thank you @Zanadar. We can gladly support the new format but we believe it should also be added to |
007ab6e to
07b63e8
Compare
de45ca3 to
65cead2
Compare
|
Added the basic format to Date, Time, and NaiveDateTime as well. |
There was a problem hiding this comment.
Generally we prefer double quotes over single quotes.
Also let's use backticks around Date.to_iso8601/2 and :basic.
There was a problem hiding this comment.
I think "human-readability" reads better here.
There was a problem hiding this comment.
I believe "human readability" is the correct way here. http://www.grammarbook.com/punctuation/hyphens.asp
There was a problem hiding this comment.
There is double spacing: "readability.<here>It also".
There was a problem hiding this comment.
I think time_to_string_extended and time_to_string_basic would be better naming for these functions. It reads better that way (since it is not about extended or basic time but about output string), also keeps them grouped by common prefix.
65cead2 to
ccd47a5
Compare
|
@lexmag Addressed those comments |
lexmag
left a comment
There was a problem hiding this comment.
Besides that last comment, it looks 👍.
|
Looking at "human-readability" vs "human readability" again, I'm inclined to agree with @whatyouhide here that the latter is actually the correct way. "Readability" is the noun that "human", the adjective, modifies, and thus there is no need for the hyphen. I could be convinced otherwise, but I guess we should have a verdict either way. |
ccd47a5 to
af52f97
Compare
- Adds support for `basic` formatting - Adds Docs and Doctests for above - Makes extended the default format for ISO_8601 formatting - DateTime.to_iso_8601 supports basic format - Date.to_iso_8601 supports basic format - Time.to_iso_8601 supports basic format - NaiveDateTime.to_iso_8601 supports basic format
af52f97 to
c0d5c0b
Compare
|
Hyphens detroyed! Should be good to go. |
|
❤️ 💚 💙 💛 💜 |
Why?
Currently, Elixir supports the
extendedformat for iso_8601 conversion. This format is good for human readability, but there is also basic format, which omits separator characters, which is often use for machine-machine messages (for example timestamps in http headers). Its easy enough to strip out the separators in a handrolled fashion, but it seems like the language should just supportbasicdirectly in addition to the already supportedextendedformat.This document gives a fairly comprehensive overview of the differences b/w extended and basic (essentially adding or omitting ':' in times and '-' in dates). I would also cite the official ISO 8601 documents but these appear to be behind paywalls.
What?
basicformatting toDateTime.to_iso8601,Time.to_iso8601,Date.to_iso8601, andNaiveDateTime.to_iso8601basicformat inCalendar.ISOfunctionsextendedthe default format option for all above