Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

add `y` pattern to CDateTimeParser #2119

Closed
wants to merge 1 commit into from

4 participants

@mrpelle

This PR resolves the issue of parsing strings ending with a 4-digits-year when "short" format is set to dd/MM/y.

See #1436

@mrpelle

Any news on this?

@resurtm
Collaborator

Not sure the fix is so obvious. In #1436 there is URL: http://www.unicode.org/cldr/trac/ticket/5347

Pedberg said:

This is fixed for CLDR 23. Note that a single 'y' will still parse a 4-digit year (or a 3-digit or 5-digit year...), in addition to formatting using as many digits as necessary with zero-padding.

I'm confused with the following part: a 4-digit year (or a 3-digit or 5-digit year...). This is not what you have in your patch.

@cebe
Owner

What is a 3-digit or 5-digit year? Do we really go that far into future/past?

@qiangxue
Owner

Postponed to 1.1.15.

@cebe cebe closed this pull request from a commit
@mrpelle mrpelle add `y` pattern to CDateTimeParser
close #2119
6e4a51a
@cebe cebe closed this in 6e4a51a
@cebe
Owner

Merged, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 15, 2013
  1. @mrpelle
This page is out of date. Refresh to see the latest.
Showing with 2 additions and 0 deletions.
  1. +2 −0  framework/utils/CDateTimeParser.php
View
2  framework/utils/CDateTimeParser.php
@@ -23,6 +23,7 @@
* MM | Month digit 01 to 12, zero leading
* MMM | Abbreviation representation of month (available since 1.1.11; locale aware since 1.1.13)
* MMMM | Full name representation (available since 1.1.13; locale aware)
+ * y | 4 year digit, e.g., 2005 (available since 1.1.14)
* yy | 2 year digit, e.g., 96, 05
* yyyy | 4 year digit, e.g., 2005
* h | Hour in 0 to 23, no padding
@@ -90,6 +91,7 @@ public static function parse($value,$pattern='MM/dd/yyyy',$defaults=array())
switch($token)
{
case 'yyyy':
+ case 'y':
{
if(($year=self::parseInteger($value,$i,4,4))===false)
return false;
Something went wrong with that request. Please try again.