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

Fix examples in Formatting and Parsing Time #6208

Merged
merged 2 commits into from Jun 18, 2018
Merged

Fix examples in Formatting and Parsing Time #6208

merged 2 commits into from Jun 18, 2018

Conversation

wooster0
Copy link
Contributor

@wooster0 wooster0 commented Jun 17, 2018

Fixes #6207

In the first example the 00 causes this error: octal constants should be prefixed with 0o so the 00 itself and the code behind it got cut off so it looks like this in the docs right now:

time = Time.utc(2015, 10, 12, 10, 30, 

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"
Copy link
Member

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?

@bcardiff bcardiff added this to the 0.25.1 milestone Jun 18, 2018
@bcardiff bcardiff merged commit 8959b54 into crystal-lang:master Jun 18, 2018
# ```
#
# 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")
Copy link
Contributor

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?

Copy link
Contributor Author

@wooster0 wooster0 Jun 18, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Examples in Formatting and Parsing Time are both wrong
5 participants