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

Enforce minimal year padding to 4 digits #33

Merged
merged 2 commits into from Mar 17, 2015
Merged

Enforce minimal year padding to 4 digits #33

merged 2 commits into from Mar 17, 2015

Conversation

thiemowmde
Copy link
Contributor

This implements an enforced padding to 4 digits for the year. This is the most minimal compromise. Look at how the DateTimeParser is implemented: It uses PHP's internal DateTime parser and needs to pad (and cut) the year to 4 digits to do this. An enforced padding to 4 digits is not crucial in this class but very convenient for almost all (external) use cases.

We can easily increase this to 16 digits later, depending on the outcome of the discussion at T66084 and related Phabricator tasks.

This also adds a test to ensure more than 16 digits for the year are not accepted.

The 1st commit is crucial, the 2nd is only a style change.

Bug: T66084

@addshore
Copy link
Contributor

addshore commented Feb 4, 2015

Looks fine to me,
I just restarted the hhvm job on travis https://travis-ci.org/DataValues/Time/jobs/49459959

* Gregorian and Julian dates use the same YMD ordered format, resembling ISO 8601, e.g.
* +2013-01-01T00:00:00Z. In this format the year is always signed and padded with zero
* characters to have between 4 and 16 digits. Month and day can be zero, indicating they are
* unknown. The timezone suffix Z is meaningless and must be ignored. Use $timezone instead.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still think we should use *, not 0, for unknown. Using 0 will break or confuse many parsers anyway, but it's not as obvious as using *.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This discussion should not happen in this patch. Please open a ticket if you think this should change. However, I disagree. As @Jc3s5h pointed out the ISO norm does this by truncating the timestamp string. We do this with our "precision" field. Everything behind is meaningless and must be ignored. In the end it doesn't matter if month and day are "01", "00" or "**". I'm voting for "00".

adrianheine added a commit that referenced this pull request Mar 17, 2015
Enforce minimal year padding to 4 digits
@adrianheine adrianheine merged commit 3183e03 into master Mar 17, 2015
@adrianheine adrianheine deleted the pad4Year branch March 17, 2015 10:42
@thiemowmde thiemowmde modified the milestone: 0.7 Apr 20, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants