-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Fix examples in Formatting and Parsing Time #6208
Conversation
src/time.cr
Outdated
@@ -127,15 +127,15 @@ require "crystal/system/time" | |||
# The method `#to_s` formats the date-time according to a specified pattern. | |||
# | |||
# ``` | |||
# time = Time.utc(2015, 10, 12, 10, 30, 00) | |||
# time = Time.utc(2015, 10, 12, 10, 30, 0) | |||
# time.to_s("%Y-%m-%d %H:%m:%s %Z") # => "2015-10-12 10:30:00 +00:00" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This %Z also needs to be changed, right?
# ``` | ||
# | ||
# Similarly, `Time.parse` is used to construct a `Time` instance from date-time | ||
# information in a string, according to a specified pattern: | ||
# | ||
# ``` | ||
# Time.parse("2015-10-12 10:30:00 +00:00", "%Y-%m-%d %H:%m:%s %Z") | ||
# Time.parse("2015-10-12 10:30:00 +00:00", "%Y-%m-%d %H:%M:%S %z") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't %z
be %:z
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No it doesn't needs to be %:z
. This gives:
2015-10-12 10:30:00 +00:00
Fixes #6207
In the first example the
00
causes this error:octal constants should be prefixed with 0o
so the00
itself and the code behind it got cut off so it looks like this in the docs right now: