Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

improvements to DataType.Date.parse #71

Merged
merged 4 commits into from

5 participants

@curtisharvey
  • return Date object when passed one (fixes #2530058, closes #2530059)
  • accept timestamp as number or string
  • remove obsolete workaround in validation
@curtisharvey curtisharvey improvements to DataType.Date.parse
- return Date object when passed one (fixes #2530058, closes #2530059)
- accept timestamp as number or string
- remove obsolete workaround in validation
d6f86cc
@allenrabinovich

Thanks for the pull request! We'll likely be revamping the parse functionality or deprecating it entirely, so I am holding on with pulling it in until all decisions are made.

@jshirley

Is there any update here? Having improved and sensible date parsing would be nice.

@allenrabinovich

The Datatype.Date revamp is on my list for the next 3.6.x release. I might be able to fix the parse bugs in the current 3.6.x sprint, as long as it doesn't interfere with future changes.

@allenrabinovich

Unfortunately, nothing changed in the parse functionality in this release (DataType.Date did get moved to just Y.Date, though). But I am working with an external contributor for the next release, and this pull request will definitely be addressed within the next month. Thanks!

@allenrabinovich

Hi, @curtisharvey. Our apologies for a long delay on this. I would like to get this functionality in, but there are a couple of issues:

  • The code for this module has moved to date/js/date-parse.js, and so we'll need a new pull request on that file with the necessary changes.
  • The new functionality needs to be unit-tested, and so changes to the date-parse unit tests need to be made (date/tests/unit/assets/date-tests.js).

Would you like to do those things and open a new pull request? This time I promise that we'll take care of it on the order of days, not months. I completely understand if you've moved on from this though, and can do these things myself if you are no longer available. Thanks!

@curtisharvey

Sorry, been super busy of late, but I will take a look at this now and try to get a updated pull request out shortly.

curtisharvey added some commits
@curtisharvey curtisharvey Merge remote-tracking branch 'upstream/master' into bug_2530058-fix-d…
…atatype-date-parse

* upstream/master: (4186 commits)
  Build files for calendar chainable methods
  Build Node. No -min changes.
  Clarified possible return of null from node.one()
  Build DataTable.
  Build QueryString. No -min changes.
  Fix QueryString's API Docs.
  cleaned up whitespace
  Added assertions for @chainable methods in calendar
  Fixed CLI test when run in full batch
  experimenting with Dial performance test writting
  Seed build
  Changed to Function constructor call
  Updated md5 sum helper
  meta-join script updates
  Made public CalendarBase and Calendar methods chainable Also fixed a little bit of whitespace
  Seed and Loader build for #2532889
  Gallery version bump
  Added tests for #2532889
  Added Y.config.global, fixes #2532889
  More Builder -> Shifter docs replacement
  ...
e84fe5f
@curtisharvey curtisharvey re-apply date parsing improvements
Needed to cleanup and reapply date parse improvements after files have
moved since pull request was first made. Also upgraded tests to both fix
an incorrect assertion and test new functionality in Y.Date.parse.
4dc0722
@curtisharvey curtisharvey adding build files for date.parse improvements 2f9b8a3
@allenrabinovich

Thanks for your contribution, @curtisharvey. I have pulled this in, and the pull request will be closed automatically in short order.

@yuibuild yuibuild merged commit 2f9b8a3 into yui:master

1 check passed

Details default The Travis build passed
@curtisharvey curtisharvey deleted the curtisharvey:bug_2530058-fix-datatype-date-parse branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 20, 2012
  1. @curtisharvey

    improvements to DataType.Date.parse

    curtisharvey authored
    - return Date object when passed one (fixes #2530058, closes #2530059)
    - accept timestamp as number or string
    - remove obsolete workaround in validation
Commits on Nov 5, 2012
  1. @curtisharvey

    Merge remote-tracking branch 'upstream/master' into bug_2530058-fix-d…

    curtisharvey authored
    …atatype-date-parse
    
    * upstream/master: (4186 commits)
      Build files for calendar chainable methods
      Build Node. No -min changes.
      Clarified possible return of null from node.one()
      Build DataTable.
      Build QueryString. No -min changes.
      Fix QueryString's API Docs.
      cleaned up whitespace
      Added assertions for @chainable methods in calendar
      Fixed CLI test when run in full batch
      experimenting with Dial performance test writting
      Seed build
      Changed to Function constructor call
      Updated md5 sum helper
      meta-join script updates
      Made public CalendarBase and Calendar methods chainable Also fixed a little bit of whitespace
      Seed and Loader build for #2532889
      Gallery version bump
      Added tests for #2532889
      Added Y.config.global, fixes #2532889
      More Builder -> Shifter docs replacement
      ...
  2. @curtisharvey

    re-apply date parsing improvements

    curtisharvey authored
    Needed to cleanup and reapply date parse improvements after files have
    moved since pull request was first made. Also upgraded tests to both fix
    an incorrect assertion and test new functionality in Y.Date.parse.
  3. @curtisharvey
This page is out of date. Refresh to see the latest.
View
87 build/datatype-date-format/datatype-date-format-coverage.js
@@ -26,7 +26,7 @@ _yuitest_coverage["build/datatype-date-format/datatype-date-format.js"] = {
path: "build/datatype-date-format/datatype-date-format.js",
code: []
};
-_yuitest_coverage["build/datatype-date-format/datatype-date-format.js"].code=["YUI.add('datatype-date-format', function (Y, NAME) {","","/**"," * The `datatype` module is an alias for three utilities, Y.Date, "," * Y.Number and Y.XML, that provide type-conversion and string-formatting"," * convenience methods for various JavaScript object types."," *"," * @module datatype"," * @main datatype"," */","","/**"," * The Date Utility provides type-conversion and string-formatting"," * convenience methods for Dates."," *"," * @module datatype-date"," * @main datatype-date"," */","","/**"," * Date module."," *"," * @module datatype-date"," */","","/**"," * Format date module implements strftime formatters for javascript based on the"," * Open Group specification defined at"," * http://www.opengroup.org/onlinepubs/007908799/xsh/strftime.html"," * This implementation does not include modified conversion specifiers (i.e., Ex and Ox)"," *"," * @module datatype-date"," * @submodule datatype-date-format"," */","","/**"," * Date provides a set of utility functions to operate against Date objects."," *"," * @class Date"," * @static"," */","","/**"," * Pad a number with leading spaces, zeroes or something else"," * @method xPad"," * @param x {Number} The number to be padded"," * @param pad {String} The character to pad the number with"," * @param r {Number} (optional) The base of the pad, eg, 10 implies to two digits, 100 implies to 3 digits."," * @private"," */","var xPad=function (x, pad, r)","{"," if(typeof r === \"undefined\")"," {"," r=10;"," }"," pad = pad + \"\"; "," for( ; parseInt(x, 10)<r && r>1; r/=10) {"," x = pad + x;"," }"," return x.toString();","};","","var Dt = {"," formats: {"," a: function (d, l) { return l.a[d.getDay()]; },"," A: function (d, l) { return l.A[d.getDay()]; },"," b: function (d, l) { return l.b[d.getMonth()]; },"," B: function (d, l) { return l.B[d.getMonth()]; },"," C: function (d) { return xPad(parseInt(d.getFullYear()/100, 10), 0); },"," d: [\"getDate\", \"0\"],"," e: [\"getDate\", \" \"],"," g: function (d) { return xPad(parseInt(Dt.formats.G(d)%100, 10), 0); },"," G: function (d) {"," var y = d.getFullYear();"," var V = parseInt(Dt.formats.V(d), 10);"," var W = parseInt(Dt.formats.W(d), 10);"," "," if(W > V) {"," y++;"," } else if(W===0 && V>=52) {"," y--;"," }"," "," return y;"," },"," H: [\"getHours\", \"0\"],"," I: function (d) { var I=d.getHours()%12; return xPad(I===0?12:I, 0); },"," j: function (d) {"," var gmd_1 = new Date(\"\" + d.getFullYear() + \"/1/1 GMT\");"," var gmdate = new Date(\"\" + d.getFullYear() + \"/\" + (d.getMonth()+1) + \"/\" + d.getDate() + \" GMT\");"," var ms = gmdate - gmd_1;"," var doy = parseInt(ms/60000/60/24, 10)+1;"," return xPad(doy, 0, 100);"," },"," k: [\"getHours\", \" \"],"," l: function (d) { var I=d.getHours()%12; return xPad(I===0?12:I, \" \"); },"," m: function (d) { return xPad(d.getMonth()+1, 0); },"," M: [\"getMinutes\", \"0\"],"," p: function (d, l) { return l.p[d.getHours() >= 12 ? 1 : 0 ]; },"," P: function (d, l) { return l.P[d.getHours() >= 12 ? 1 : 0 ]; },"," s: function (d, l) { return parseInt(d.getTime()/1000, 10); },"," S: [\"getSeconds\", \"0\"],"," u: function (d) { var dow = d.getDay(); return dow===0?7:dow; },"," U: function (d) {"," var doy = parseInt(Dt.formats.j(d), 10);"," var rdow = 6-d.getDay();"," var woy = parseInt((doy+rdow)/7, 10);"," return xPad(woy, 0);"," },"," V: function (d) {"," var woy = parseInt(Dt.formats.W(d), 10);"," var dow1_1 = (new Date(\"\" + d.getFullYear() + \"/1/1\")).getDay();"," // First week is 01 and not 00 as in the case of %U and %W,"," // so we add 1 to the final result except if day 1 of the year"," // is a Monday (then %W returns 01)."," // We also need to subtract 1 if the day 1 of the year is "," // Friday-Sunday, so the resulting equation becomes:"," var idow = woy + (dow1_1 > 4 || dow1_1 <= 1 ? 0 : 1);"," if(idow === 53 && (new Date(\"\" + d.getFullYear() + \"/12/31\")).getDay() < 4)"," {"," idow = 1;"," }"," else if(idow === 0)"," {"," idow = Dt.formats.V(new Date(\"\" + (d.getFullYear()-1) + \"/12/31\"));"," }"," "," return xPad(idow, 0);"," },"," w: \"getDay\","," W: function (d) {"," var doy = parseInt(Dt.formats.j(d), 10);"," var rdow = 7-Dt.formats.u(d);"," var woy = parseInt((doy+rdow)/7, 10);"," return xPad(woy, 0, 10);"," },"," y: function (d) { return xPad(d.getFullYear()%100, 0); },"," Y: \"getFullYear\","," z: function (d) {"," var o = d.getTimezoneOffset();"," var H = xPad(parseInt(Math.abs(o/60), 10), 0);"," var M = xPad(Math.abs(o%60), 0);"," return (o>0?\"-\":\"+\") + H + M;"," },"," Z: function (d) {"," var tz = d.toString().replace(/^.*:\\d\\d( GMT[+-]\\d+)? \\(?([A-Za-z ]+)\\)?\\d*$/, \"$2\").replace(/[a-z ]/g, \"\");"," if(tz.length > 4) {"," tz = Dt.formats.z(d);"," }"," return tz;"," },"," \"%\": function (d) { return \"%\"; }"," },",""," aggregates: {"," c: \"locale\","," D: \"%m/%d/%y\","," F: \"%Y-%m-%d\","," h: \"%b\","," n: \"\\n\","," r: \"%I:%M:%S %p\","," R: \"%H:%M\","," t: \"\\t\","," T: \"%H:%M:%S\","," x: \"locale\","," X: \"locale\""," //\"+\": \"%a %b %e %T %Z %Y\""," },",""," /**"," * Takes a native JavaScript Date and formats it as a string for display to user."," *"," * @for Date"," * @method format"," * @param oDate {Date} Date."," * @param oConfig {Object} (Optional) Object literal of configuration values:"," * <dl>"," * <dt>format {HTML} (Optional)</dt>"," * <dd>"," * <p>"," * Any strftime string is supported, such as \"%I:%M:%S %p\". strftime has several format specifiers defined by the Open group at "," * <a href=\"http://www.opengroup.org/onlinepubs/007908799/xsh/strftime.html\">http://www.opengroup.org/onlinepubs/007908799/xsh/strftime.html</a>"," * PHP added a few of its own, defined at <a href=\"http://www.php.net/strftime\">http://www.php.net/strftime</a>"," * </p>"," * <p>"," * This javascript implementation supports all the PHP specifiers and a few more. The full list is below."," * </p>"," * <p>"," * If not specified, it defaults to the ISO 8601 standard date format: %Y-%m-%d."," * </p>"," * <dl>"," * <dt>%a</dt> <dd>abbreviated weekday name according to the current locale</dd>"," * <dt>%A</dt> <dd>full weekday name according to the current locale</dd>"," * <dt>%b</dt> <dd>abbreviated month name according to the current locale</dd>"," * <dt>%B</dt> <dd>full month name according to the current locale</dd>"," * <dt>%c</dt> <dd>preferred date and time representation for the current locale</dd>"," * <dt>%C</dt> <dd>century number (the year divided by 100 and truncated to an integer, range 00 to 99)</dd>"," * <dt>%d</dt> <dd>day of the month as a decimal number (range 01 to 31)</dd>"," * <dt>%D</dt> <dd>same as %m/%d/%y</dd>"," * <dt>%e</dt> <dd>day of the month as a decimal number, a single digit is preceded by a space (range \" 1\" to \"31\")</dd>"," * <dt>%F</dt> <dd>same as %Y-%m-%d (ISO 8601 date format)</dd>"," * <dt>%g</dt> <dd>like %G, but without the century</dd>"," * <dt>%G</dt> <dd>The 4-digit year corresponding to the ISO week number</dd>"," * <dt>%h</dt> <dd>same as %b</dd>"," * <dt>%H</dt> <dd>hour as a decimal number using a 24-hour clock (range 00 to 23)</dd>"," * <dt>%I</dt> <dd>hour as a decimal number using a 12-hour clock (range 01 to 12)</dd>"," * <dt>%j</dt> <dd>day of the year as a decimal number (range 001 to 366)</dd>"," * <dt>%k</dt> <dd>hour as a decimal number using a 24-hour clock (range 0 to 23); single digits are preceded by a blank. (See also %H.)</dd>"," * <dt>%l</dt> <dd>hour as a decimal number using a 12-hour clock (range 1 to 12); single digits are preceded by a blank. (See also %I.) </dd>"," * <dt>%m</dt> <dd>month as a decimal number (range 01 to 12)</dd>"," * <dt>%M</dt> <dd>minute as a decimal number</dd>"," * <dt>%n</dt> <dd>newline character</dd>"," * <dt>%p</dt> <dd>either \"AM\" or \"PM\" according to the given time value, or the corresponding strings for the current locale</dd>"," * <dt>%P</dt> <dd>like %p, but lower case</dd>"," * <dt>%r</dt> <dd>time in a.m. and p.m. notation equal to %I:%M:%S %p</dd>"," * <dt>%R</dt> <dd>time in 24 hour notation equal to %H:%M</dd>"," * <dt>%s</dt> <dd>number of seconds since the Epoch, ie, since 1970-01-01 00:00:00 UTC</dd>"," * <dt>%S</dt> <dd>second as a decimal number</dd>"," * <dt>%t</dt> <dd>tab character</dd>"," * <dt>%T</dt> <dd>current time, equal to %H:%M:%S</dd>"," * <dt>%u</dt> <dd>weekday as a decimal number [1,7], with 1 representing Monday</dd>"," * <dt>%U</dt> <dd>week number of the current year as a decimal number, starting with the"," * first Sunday as the first day of the first week</dd>"," * <dt>%V</dt> <dd>The ISO 8601:1988 week number of the current year as a decimal number,"," * range 01 to 53, where week 1 is the first week that has at least 4 days"," * in the current year, and with Monday as the first day of the week.</dd>"," * <dt>%w</dt> <dd>day of the week as a decimal, Sunday being 0</dd>"," * <dt>%W</dt> <dd>week number of the current year as a decimal number, starting with the"," * first Monday as the first day of the first week</dd>"," * <dt>%x</dt> <dd>preferred date representation for the current locale without the time</dd>"," * <dt>%X</dt> <dd>preferred time representation for the current locale without the date</dd>"," * <dt>%y</dt> <dd>year as a decimal number without a century (range 00 to 99)</dd>"," * <dt>%Y</dt> <dd>year as a decimal number including the century</dd>"," * <dt>%z</dt> <dd>numerical time zone representation</dd>"," * <dt>%Z</dt> <dd>time zone name or abbreviation</dd>"," * <dt>%%</dt> <dd>a literal \"%\" character</dd>"," * </dl>"," * </dd>"," * </dl>"," * @return {HTML} Formatted date for display."," */"," format : function (oDate, oConfig) {"," oConfig = oConfig || {};"," "," if(!Y.Lang.isDate(oDate)) {"," return Y.Lang.isValue(oDate) ? oDate : \"\";"," }",""," var format, resources, compatMode, sLocale, LOCALE;",""," format = oConfig.format || \"%Y-%m-%d\";",""," resources = Y.Intl.get('datatype-date-format');",""," var replace_aggs = function (m0, m1) {"," if (compatMode && m1 === \"r\") {"," return resources[m1];"," }"," var f = Dt.aggregates[m1];"," return (f === \"locale\" ? resources[m1] : f);"," };",""," var replace_formats = function (m0, m1) {"," var f = Dt.formats[m1];"," switch(Y.Lang.type(f)) {"," case \"string\": // string => built in date function"," return oDate[f]();"," case \"function\": // function => our own function"," return f.call(oDate, oDate, resources);"," case \"array\": // built in function with padding"," if(Y.Lang.type(f[0]) === \"string\") {"," return xPad(oDate[f[0]](), f[1]);"," } // no break; (fall through to default:)"," default:"," return m1;"," }"," };",""," // First replace aggregates (run in a loop because an agg may be made up of other aggs)"," while(format.match(/%[cDFhnrRtTxX]/)) {"," format = format.replace(/%([cDFhnrRtTxX])/g, replace_aggs);"," }",""," // Now replace formats (do not run in a loop otherwise %%a will be replace with the value of %a)"," var str = format.replace(/%([aAbBCdegGHIjklmMpPsSuUVwWyYzZ%])/g, replace_formats);",""," replace_aggs = replace_formats = undefined;",""," return str;"," }","};","","Y.mix(Y.namespace(\"Date\"), Dt);","","","Y.namespace(\"DataType\");","Y.DataType.Date = Y.Date;","","","}, '@VERSION@', {\"lang\": [\"ar\", \"ar-JO\", \"ca\", \"ca-ES\", \"da\", \"da-DK\", \"de\", \"de-AT\", \"de-DE\", \"el\", \"el-GR\", \"en\", \"en-AU\", \"en-CA\", \"en-GB\", \"en-IE\", \"en-IN\", \"en-JO\", \"en-MY\", \"en-NZ\", \"en-PH\", \"en-SG\", \"en-US\", \"es\", \"es-AR\", \"es-BO\", \"es-CL\", \"es-CO\", \"es-EC\", \"es-ES\", \"es-MX\", \"es-PE\", \"es-PY\", \"es-US\", \"es-UY\", \"es-VE\", \"fi\", \"fi-FI\", \"fr\", \"fr-BE\", \"fr-CA\", \"fr-FR\", \"hi\", \"hi-IN\", \"id\", \"id-ID\", \"it\", \"it-IT\", \"ja\", \"ja-JP\", \"ko\", \"ko-KR\", \"ms\", \"ms-MY\", \"nb\", \"nb-NO\", \"nl\", \"nl-BE\", \"nl-NL\", \"pl\", \"pl-PL\", \"pt\", \"pt-BR\", \"ro\", \"ro-RO\", \"ru\", \"ru-RU\", \"sv\", \"sv-SE\", \"th\", \"th-TH\", \"tr\", \"tr-TR\", \"vi\", \"vi-VN\", \"zh-Hans\", \"zh-Hans-CN\", \"zh-Hant\", \"zh-Hant-HK\", \"zh-Hant-TW\"]});"];
+_yuitest_coverage["build/datatype-date-format/datatype-date-format.js"].code=["YUI.add('datatype-date-format', function (Y, NAME) {","","/**"," * The `datatype` module is an alias for three utilities, Y.Date, "," * Y.Number and Y.XML, that provide type-conversion and string-formatting"," * convenience methods for various JavaScript object types."," *"," * @module datatype"," * @main datatype"," */","","/**"," * The Date Utility provides type-conversion and string-formatting"," * convenience methods for Dates."," *"," * @module datatype-date"," * @main datatype-date"," */","","/**"," * Date module."," *"," * @module datatype-date"," */","","/**"," * Format date module implements strftime formatters for javascript based on the"," * Open Group specification defined at"," * http://www.opengroup.org/onlinepubs/007908799/xsh/strftime.html"," * This implementation does not include modified conversion specifiers (i.e., Ex and Ox)"," *"," * @module datatype-date"," * @submodule datatype-date-format"," */","","/**"," * Date provides a set of utility functions to operate against Date objects."," *"," * @class Date"," * @static"," */","","/**"," * Pad a number with leading spaces, zeroes or something else"," * @method xPad"," * @param x {Number} The number to be padded"," * @param pad {String} The character to pad the number with"," * @param r {Number} (optional) The base of the pad, eg, 10 implies to two digits, 100 implies to 3 digits."," * @private"," */","var xPad=function (x, pad, r)","{"," if(typeof r === \"undefined\")"," {"," r=10;"," }"," pad = pad + \"\"; "," for( ; parseInt(x, 10)<r && r>1; r/=10) {"," x = pad + x;"," }"," return x.toString();","};","","var Dt = {"," formats: {"," a: function (d, l) { return l.a[d.getDay()]; },"," A: function (d, l) { return l.A[d.getDay()]; },"," b: function (d, l) { return l.b[d.getMonth()]; },"," B: function (d, l) { return l.B[d.getMonth()]; },"," C: function (d) { return xPad(parseInt(d.getFullYear()/100, 10), 0); },"," d: [\"getDate\", \"0\"],"," e: [\"getDate\", \" \"],"," g: function (d) { return xPad(parseInt(Dt.formats.G(d)%100, 10), 0); },"," G: function (d) {"," var y = d.getFullYear();"," var V = parseInt(Dt.formats.V(d), 10);"," var W = parseInt(Dt.formats.W(d), 10);"," "," if(W > V) {"," y++;"," } else if(W===0 && V>=52) {"," y--;"," }"," "," return y;"," },"," H: [\"getHours\", \"0\"],"," I: function (d) { var I=d.getHours()%12; return xPad(I===0?12:I, 0); },"," j: function (d) {"," var gmd_1 = new Date(\"\" + d.getFullYear() + \"/1/1 GMT\");"," var gmdate = new Date(\"\" + d.getFullYear() + \"/\" + (d.getMonth()+1) + \"/\" + d.getDate() + \" GMT\");"," var ms = gmdate - gmd_1;"," var doy = parseInt(ms/60000/60/24, 10)+1;"," return xPad(doy, 0, 100);"," },"," k: [\"getHours\", \" \"],"," l: function (d) { var I=d.getHours()%12; return xPad(I===0?12:I, \" \"); },"," m: function (d) { return xPad(d.getMonth()+1, 0); },"," M: [\"getMinutes\", \"0\"],"," p: function (d, l) { return l.p[d.getHours() >= 12 ? 1 : 0 ]; },"," P: function (d, l) { return l.P[d.getHours() >= 12 ? 1 : 0 ]; },"," s: function (d, l) { return parseInt(d.getTime()/1000, 10); },"," S: [\"getSeconds\", \"0\"],"," u: function (d) { var dow = d.getDay(); return dow===0?7:dow; },"," U: function (d) {"," var doy = parseInt(Dt.formats.j(d), 10);"," var rdow = 6-d.getDay();"," var woy = parseInt((doy+rdow)/7, 10);"," return xPad(woy, 0);"," },"," V: function (d) {"," var woy = parseInt(Dt.formats.W(d), 10);"," var dow1_1 = (new Date(\"\" + d.getFullYear() + \"/1/1\")).getDay();"," // First week is 01 and not 00 as in the case of %U and %W,"," // so we add 1 to the final result except if day 1 of the year"," // is a Monday (then %W returns 01)."," // We also need to subtract 1 if the day 1 of the year is "," // Friday-Sunday, so the resulting equation becomes:"," var idow = woy + (dow1_1 > 4 || dow1_1 <= 1 ? 0 : 1);"," if(idow === 53 && (new Date(\"\" + d.getFullYear() + \"/12/31\")).getDay() < 4)"," {"," idow = 1;"," }"," else if(idow === 0)"," {"," idow = Dt.formats.V(new Date(\"\" + (d.getFullYear()-1) + \"/12/31\"));"," }"," "," return xPad(idow, 0);"," },"," w: \"getDay\","," W: function (d) {"," var doy = parseInt(Dt.formats.j(d), 10);"," var rdow = 7-Dt.formats.u(d);"," var woy = parseInt((doy+rdow)/7, 10);"," return xPad(woy, 0, 10);"," },"," y: function (d) { return xPad(d.getFullYear()%100, 0); },"," Y: \"getFullYear\","," z: function (d) {"," var o = d.getTimezoneOffset();"," var H = xPad(parseInt(Math.abs(o/60), 10), 0);"," var M = xPad(Math.abs(o%60), 0);"," return (o>0?\"-\":\"+\") + H + M;"," },"," Z: function (d) {"," var tz = d.toString().replace(/^.*:\\d\\d( GMT[+-]\\d+)? \\(?([A-Za-z ]+)\\)?\\d*$/, \"$2\").replace(/[a-z ]/g, \"\");"," if(tz.length > 4) {"," tz = Dt.formats.z(d);"," }"," return tz;"," },"," \"%\": function (d) { return \"%\"; }"," },",""," aggregates: {"," c: \"locale\","," D: \"%m/%d/%y\","," F: \"%Y-%m-%d\","," h: \"%b\","," n: \"\\n\","," r: \"%I:%M:%S %p\","," R: \"%H:%M\","," t: \"\\t\","," T: \"%H:%M:%S\","," x: \"locale\","," X: \"locale\""," //\"+\": \"%a %b %e %T %Z %Y\""," },",""," /**"," * Takes a native JavaScript Date and formats it as a string for display to user."," *"," * @for Date"," * @method format"," * @param oDate {Date} Date."," * @param oConfig {Object} (Optional) Object literal of configuration values:"," * <dl>"," * <dt>format {HTML} (Optional)</dt>"," * <dd>"," * <p>"," * Any strftime string is supported, such as \"%I:%M:%S %p\". strftime has several format specifiers defined by the Open group at "," * <a href=\"http://www.opengroup.org/onlinepubs/007908799/xsh/strftime.html\">http://www.opengroup.org/onlinepubs/007908799/xsh/strftime.html</a>"," * PHP added a few of its own, defined at <a href=\"http://www.php.net/strftime\">http://www.php.net/strftime</a>"," * </p>"," * <p>"," * This javascript implementation supports all the PHP specifiers and a few more. The full list is below."," * </p>"," * <p>"," * If not specified, it defaults to the ISO 8601 standard date format: %Y-%m-%d."," * </p>"," * <dl>"," * <dt>%a</dt> <dd>abbreviated weekday name according to the current locale</dd>"," * <dt>%A</dt> <dd>full weekday name according to the current locale</dd>"," * <dt>%b</dt> <dd>abbreviated month name according to the current locale</dd>"," * <dt>%B</dt> <dd>full month name according to the current locale</dd>"," * <dt>%c</dt> <dd>preferred date and time representation for the current locale</dd>"," * <dt>%C</dt> <dd>century number (the year divided by 100 and truncated to an integer, range 00 to 99)</dd>"," * <dt>%d</dt> <dd>day of the month as a decimal number (range 01 to 31)</dd>"," * <dt>%D</dt> <dd>same as %m/%d/%y</dd>"," * <dt>%e</dt> <dd>day of the month as a decimal number, a single digit is preceded by a space (range \" 1\" to \"31\")</dd>"," * <dt>%F</dt> <dd>same as %Y-%m-%d (ISO 8601 date format)</dd>"," * <dt>%g</dt> <dd>like %G, but without the century</dd>"," * <dt>%G</dt> <dd>The 4-digit year corresponding to the ISO week number</dd>"," * <dt>%h</dt> <dd>same as %b</dd>"," * <dt>%H</dt> <dd>hour as a decimal number using a 24-hour clock (range 00 to 23)</dd>"," * <dt>%I</dt> <dd>hour as a decimal number using a 12-hour clock (range 01 to 12)</dd>"," * <dt>%j</dt> <dd>day of the year as a decimal number (range 001 to 366)</dd>"," * <dt>%k</dt> <dd>hour as a decimal number using a 24-hour clock (range 0 to 23); single digits are preceded by a blank. (See also %H.)</dd>"," * <dt>%l</dt> <dd>hour as a decimal number using a 12-hour clock (range 1 to 12); single digits are preceded by a blank. (See also %I.) </dd>"," * <dt>%m</dt> <dd>month as a decimal number (range 01 to 12)</dd>"," * <dt>%M</dt> <dd>minute as a decimal number</dd>"," * <dt>%n</dt> <dd>newline character</dd>"," * <dt>%p</dt> <dd>either \"AM\" or \"PM\" according to the given time value, or the corresponding strings for the current locale</dd>"," * <dt>%P</dt> <dd>like %p, but lower case</dd>"," * <dt>%r</dt> <dd>time in a.m. and p.m. notation equal to %I:%M:%S %p</dd>"," * <dt>%R</dt> <dd>time in 24 hour notation equal to %H:%M</dd>"," * <dt>%s</dt> <dd>number of seconds since the Epoch, ie, since 1970-01-01 00:00:00 UTC</dd>"," * <dt>%S</dt> <dd>second as a decimal number</dd>"," * <dt>%t</dt> <dd>tab character</dd>"," * <dt>%T</dt> <dd>current time, equal to %H:%M:%S</dd>"," * <dt>%u</dt> <dd>weekday as a decimal number [1,7], with 1 representing Monday</dd>"," * <dt>%U</dt> <dd>week number of the current year as a decimal number, starting with the"," * first Sunday as the first day of the first week</dd>"," * <dt>%V</dt> <dd>The ISO 8601:1988 week number of the current year as a decimal number,"," * range 01 to 53, where week 1 is the first week that has at least 4 days"," * in the current year, and with Monday as the first day of the week.</dd>"," * <dt>%w</dt> <dd>day of the week as a decimal, Sunday being 0</dd>"," * <dt>%W</dt> <dd>week number of the current year as a decimal number, starting with the"," * first Monday as the first day of the first week</dd>"," * <dt>%x</dt> <dd>preferred date representation for the current locale without the time</dd>"," * <dt>%X</dt> <dd>preferred time representation for the current locale without the date</dd>"," * <dt>%y</dt> <dd>year as a decimal number without a century (range 00 to 99)</dd>"," * <dt>%Y</dt> <dd>year as a decimal number including the century</dd>"," * <dt>%z</dt> <dd>numerical time zone representation</dd>"," * <dt>%Z</dt> <dd>time zone name or abbreviation</dd>"," * <dt>%%</dt> <dd>a literal \"%\" character</dd>"," * </dl>"," * </dd>"," * </dl>"," * @return {HTML} Formatted date for display."," */"," format : function (oDate, oConfig) {"," oConfig = oConfig || {};"," "," if(!Y.Lang.isDate(oDate)) {"," return Y.Lang.isValue(oDate) ? oDate : \"\";"," }",""," var format, resources, compatMode, sLocale, LOCALE;",""," format = oConfig.format || \"%Y-%m-%d\";",""," resources = Y.Intl.get('datatype-date-format');",""," var replace_aggs = function (m0, m1) {"," if (compatMode && m1 === \"r\") {"," return resources[m1];"," }"," var f = Dt.aggregates[m1];"," return (f === \"locale\" ? resources[m1] : f);"," };",""," var replace_formats = function (m0, m1) {"," var f = Dt.formats[m1];"," switch(Y.Lang.type(f)) {"," case \"string\": // string => built in date function"," return oDate[f]();"," case \"function\": // function => our own function"," return f.call(oDate, oDate, resources);"," case \"array\": // built in function with padding"," if(Y.Lang.type(f[0]) === \"string\") {"," return xPad(oDate[f[0]](), f[1]);"," } // no break; (fall through to default:)"," default:"," return m1;"," }"," };",""," // First replace aggregates (run in a loop because an agg may be made up of other aggs)"," while(format.match(/%[cDFhnrRtTxX]/)) {"," format = format.replace(/%([cDFhnrRtTxX])/g, replace_aggs);"," }",""," // Now replace formats (do not run in a loop otherwise %%a will be replace with the value of %a)"," var str = format.replace(/%([aAbBCdegGHIjklmMpPsSuUVwWyYzZ%])/g, replace_formats);",""," replace_aggs = replace_formats = undefined;",""," return str;"," }","};","","Y.mix(Y.namespace(\"Date\"), Dt);","","","Y.namespace(\"DataType\");","Y.DataType.Date = Y.Date;","","","}, '@VERSION@', {"," \"lang\": ["," \"ar\","," \"ar-JO\","," \"ca\","," \"ca-ES\","," \"da\","," \"da-DK\","," \"de\","," \"de-AT\","," \"de-DE\","," \"el\","," \"el-GR\","," \"en\","," \"en-AU\","," \"en-CA\","," \"en-GB\","," \"en-IE\","," \"en-IN\","," \"en-JO\","," \"en-MY\","," \"en-NZ\","," \"en-PH\","," \"en-SG\","," \"en-US\","," \"es\","," \"es-AR\","," \"es-BO\","," \"es-CL\","," \"es-CO\","," \"es-EC\","," \"es-ES\","," \"es-MX\","," \"es-PE\","," \"es-PY\","," \"es-US\","," \"es-UY\","," \"es-VE\","," \"fi\","," \"fi-FI\","," \"fr\","," \"fr-BE\","," \"fr-CA\","," \"fr-FR\","," \"hi\","," \"hi-IN\","," \"id\","," \"id-ID\","," \"it\","," \"it-IT\","," \"ja\","," \"ja-JP\","," \"ko\","," \"ko-KR\","," \"ms\","," \"ms-MY\","," \"nb\","," \"nb-NO\","," \"nl\","," \"nl-BE\","," \"nl-NL\","," \"pl\","," \"pl-PL\","," \"pt\","," \"pt-BR\","," \"ro\","," \"ro-RO\","," \"ru\","," \"ru-RU\","," \"sv\","," \"sv-SE\","," \"th\","," \"th-TH\","," \"tr\","," \"tr-TR\","," \"vi\","," \"vi-VN\","," \"zh-Hans\","," \"zh-Hans-CN\","," \"zh-Hant\","," \"zh-Hant-HK\","," \"zh-Hant-TW\""," ]","});"];
_yuitest_coverage["build/datatype-date-format/datatype-date-format.js"].lines = {"1":0,"51":0,"53":0,"55":0,"57":0,"58":0,"59":0,"61":0,"64":0,"66":0,"67":0,"68":0,"69":0,"70":0,"73":0,"75":0,"76":0,"77":0,"79":0,"80":0,"81":0,"82":0,"85":0,"88":0,"90":0,"91":0,"92":0,"93":0,"94":0,"97":0,"98":0,"100":0,"101":0,"102":0,"104":0,"106":0,"107":0,"108":0,"109":0,"112":0,"113":0,"119":0,"120":0,"122":0,"124":0,"126":0,"129":0,"133":0,"134":0,"135":0,"136":0,"138":0,"141":0,"142":0,"143":0,"144":0,"147":0,"148":0,"149":0,"151":0,"153":0,"244":0,"246":0,"247":0,"250":0,"252":0,"254":0,"256":0,"257":0,"258":0,"260":0,"261":0,"264":0,"265":0,"266":0,"268":0,"270":0,"272":0,"273":0,"276":0,"281":0,"282":0,"286":0,"288":0,"290":0,"294":0,"297":0,"298":0};
_yuitest_coverage["build/datatype-date-format/datatype-date-format.js"].functions = {"xPad:51":0,"a:66":0,"A:67":0,"b:68":0,"B:69":0,"C:70":0,"g:73":0,"G:74":0,"I:88":0,"j:89":0,"l:97":0,"m:98":0,"p:100":0,"P:101":0,"s:102":0,"u:104":0,"U:105":0,"V:111":0,"W:132":0,"y:138":0,"z:140":0,"Z:146":0,"\"%\":153":0,"replace_aggs:256":0,"replace_formats:264":0,"format:243":0,"(anonymous 1):1":0};
_yuitest_coverage["build/datatype-date-format/datatype-date-format.js"].coveredLines = 88;
@@ -446,4 +446,87 @@ _yuitest_coverline("build/datatype-date-format/datatype-date-format.js", 298);
Y.DataType.Date = Y.Date;
-}, '@VERSION@', {"lang": ["ar", "ar-JO", "ca", "ca-ES", "da", "da-DK", "de", "de-AT", "de-DE", "el", "el-GR", "en", "en-AU", "en-CA", "en-GB", "en-IE", "en-IN", "en-JO", "en-MY", "en-NZ", "en-PH", "en-SG", "en-US", "es", "es-AR", "es-BO", "es-CL", "es-CO", "es-EC", "es-ES", "es-MX", "es-PE", "es-PY", "es-US", "es-UY", "es-VE", "fi", "fi-FI", "fr", "fr-BE", "fr-CA", "fr-FR", "hi", "hi-IN", "id", "id-ID", "it", "it-IT", "ja", "ja-JP", "ko", "ko-KR", "ms", "ms-MY", "nb", "nb-NO", "nl", "nl-BE", "nl-NL", "pl", "pl-PL", "pt", "pt-BR", "ro", "ro-RO", "ru", "ru-RU", "sv", "sv-SE", "th", "th-TH", "tr", "tr-TR", "vi", "vi-VN", "zh-Hans", "zh-Hans-CN", "zh-Hant", "zh-Hant-HK", "zh-Hant-TW"]});
+}, '@VERSION@', {
+ "lang": [
+ "ar",
+ "ar-JO",
+ "ca",
+ "ca-ES",
+ "da",
+ "da-DK",
+ "de",
+ "de-AT",
+ "de-DE",
+ "el",
+ "el-GR",
+ "en",
+ "en-AU",
+ "en-CA",
+ "en-GB",
+ "en-IE",
+ "en-IN",
+ "en-JO",
+ "en-MY",
+ "en-NZ",
+ "en-PH",
+ "en-SG",
+ "en-US",
+ "es",
+ "es-AR",
+ "es-BO",
+ "es-CL",
+ "es-CO",
+ "es-EC",
+ "es-ES",
+ "es-MX",
+ "es-PE",
+ "es-PY",
+ "es-US",
+ "es-UY",
+ "es-VE",
+ "fi",
+ "fi-FI",
+ "fr",
+ "fr-BE",
+ "fr-CA",
+ "fr-FR",
+ "hi",
+ "hi-IN",
+ "id",
+ "id-ID",
+ "it",
+ "it-IT",
+ "ja",
+ "ja-JP",
+ "ko",
+ "ko-KR",
+ "ms",
+ "ms-MY",
+ "nb",
+ "nb-NO",
+ "nl",
+ "nl-BE",
+ "nl-NL",
+ "pl",
+ "pl-PL",
+ "pt",
+ "pt-BR",
+ "ro",
+ "ro-RO",
+ "ru",
+ "ru-RU",
+ "sv",
+ "sv-SE",
+ "th",
+ "th-TH",
+ "tr",
+ "tr-TR",
+ "vi",
+ "vi-VN",
+ "zh-Hans",
+ "zh-Hans-CN",
+ "zh-Hant",
+ "zh-Hant-HK",
+ "zh-Hant-TW"
+ ]
+});
View
85 build/datatype-date-format/datatype-date-format-debug.js
@@ -300,4 +300,87 @@ Y.namespace("DataType");
Y.DataType.Date = Y.Date;
-}, '@VERSION@', {"lang": ["ar", "ar-JO", "ca", "ca-ES", "da", "da-DK", "de", "de-AT", "de-DE", "el", "el-GR", "en", "en-AU", "en-CA", "en-GB", "en-IE", "en-IN", "en-JO", "en-MY", "en-NZ", "en-PH", "en-SG", "en-US", "es", "es-AR", "es-BO", "es-CL", "es-CO", "es-EC", "es-ES", "es-MX", "es-PE", "es-PY", "es-US", "es-UY", "es-VE", "fi", "fi-FI", "fr", "fr-BE", "fr-CA", "fr-FR", "hi", "hi-IN", "id", "id-ID", "it", "it-IT", "ja", "ja-JP", "ko", "ko-KR", "ms", "ms-MY", "nb", "nb-NO", "nl", "nl-BE", "nl-NL", "pl", "pl-PL", "pt", "pt-BR", "ro", "ro-RO", "ru", "ru-RU", "sv", "sv-SE", "th", "th-TH", "tr", "tr-TR", "vi", "vi-VN", "zh-Hans", "zh-Hans-CN", "zh-Hant", "zh-Hant-HK", "zh-Hant-TW"]});
+}, '@VERSION@', {
+ "lang": [
+ "ar",
+ "ar-JO",
+ "ca",
+ "ca-ES",
+ "da",
+ "da-DK",
+ "de",
+ "de-AT",
+ "de-DE",
+ "el",
+ "el-GR",
+ "en",
+ "en-AU",
+ "en-CA",
+ "en-GB",
+ "en-IE",
+ "en-IN",
+ "en-JO",
+ "en-MY",
+ "en-NZ",
+ "en-PH",
+ "en-SG",
+ "en-US",
+ "es",
+ "es-AR",
+ "es-BO",
+ "es-CL",
+ "es-CO",
+ "es-EC",
+ "es-ES",
+ "es-MX",
+ "es-PE",
+ "es-PY",
+ "es-US",
+ "es-UY",
+ "es-VE",
+ "fi",
+ "fi-FI",
+ "fr",
+ "fr-BE",
+ "fr-CA",
+ "fr-FR",
+ "hi",
+ "hi-IN",
+ "id",
+ "id-ID",
+ "it",
+ "it-IT",
+ "ja",
+ "ja-JP",
+ "ko",
+ "ko-KR",
+ "ms",
+ "ms-MY",
+ "nb",
+ "nb-NO",
+ "nl",
+ "nl-BE",
+ "nl-NL",
+ "pl",
+ "pl-PL",
+ "pt",
+ "pt-BR",
+ "ro",
+ "ro-RO",
+ "ru",
+ "ru-RU",
+ "sv",
+ "sv-SE",
+ "th",
+ "th-TH",
+ "tr",
+ "tr-TR",
+ "vi",
+ "vi-VN",
+ "zh-Hans",
+ "zh-Hans-CN",
+ "zh-Hant",
+ "zh-Hant-HK",
+ "zh-Hant-TW"
+ ]
+});
View
85 build/datatype-date-format/datatype-date-format.js
@@ -298,4 +298,87 @@ Y.namespace("DataType");
Y.DataType.Date = Y.Date;
-}, '@VERSION@', {"lang": ["ar", "ar-JO", "ca", "ca-ES", "da", "da-DK", "de", "de-AT", "de-DE", "el", "el-GR", "en", "en-AU", "en-CA", "en-GB", "en-IE", "en-IN", "en-JO", "en-MY", "en-NZ", "en-PH", "en-SG", "en-US", "es", "es-AR", "es-BO", "es-CL", "es-CO", "es-EC", "es-ES", "es-MX", "es-PE", "es-PY", "es-US", "es-UY", "es-VE", "fi", "fi-FI", "fr", "fr-BE", "fr-CA", "fr-FR", "hi", "hi-IN", "id", "id-ID", "it", "it-IT", "ja", "ja-JP", "ko", "ko-KR", "ms", "ms-MY", "nb", "nb-NO", "nl", "nl-BE", "nl-NL", "pl", "pl-PL", "pt", "pt-BR", "ro", "ro-RO", "ru", "ru-RU", "sv", "sv-SE", "th", "th-TH", "tr", "tr-TR", "vi", "vi-VN", "zh-Hans", "zh-Hans-CN", "zh-Hant", "zh-Hant-HK", "zh-Hant-TW"]});
+}, '@VERSION@', {
+ "lang": [
+ "ar",
+ "ar-JO",
+ "ca",
+ "ca-ES",
+ "da",
+ "da-DK",
+ "de",
+ "de-AT",
+ "de-DE",
+ "el",
+ "el-GR",
+ "en",
+ "en-AU",
+ "en-CA",
+ "en-GB",
+ "en-IE",
+ "en-IN",
+ "en-JO",
+ "en-MY",
+ "en-NZ",
+ "en-PH",
+ "en-SG",
+ "en-US",
+ "es",
+ "es-AR",
+ "es-BO",
+ "es-CL",
+ "es-CO",
+ "es-EC",
+ "es-ES",
+ "es-MX",
+ "es-PE",
+ "es-PY",
+ "es-US",
+ "es-UY",
+ "es-VE",
+ "fi",
+ "fi-FI",
+ "fr",
+ "fr-BE",
+ "fr-CA",
+ "fr-FR",
+ "hi",
+ "hi-IN",
+ "id",
+ "id-ID",
+ "it",
+ "it-IT",
+ "ja",
+ "ja-JP",
+ "ko",
+ "ko-KR",
+ "ms",
+ "ms-MY",
+ "nb",
+ "nb-NO",
+ "nl",
+ "nl-BE",
+ "nl-NL",
+ "pl",
+ "pl-PL",
+ "pt",
+ "pt-BR",
+ "ro",
+ "ro-RO",
+ "ru",
+ "ru-RU",
+ "sv",
+ "sv-SE",
+ "th",
+ "th-TH",
+ "tr",
+ "tr-TR",
+ "vi",
+ "vi-VN",
+ "zh-Hans",
+ "zh-Hans-CN",
+ "zh-Hant",
+ "zh-Hant-HK",
+ "zh-Hant-TW"
+ ]
+});
View
53 build/datatype-date-parse/datatype-date-parse-coverage.js
@@ -26,10 +26,10 @@ _yuitest_coverage["build/datatype-date-parse/datatype-date-parse.js"] = {
path: "build/datatype-date-parse/datatype-date-parse.js",
code: []
};
-_yuitest_coverage["build/datatype-date-parse/datatype-date-parse.js"].code=["YUI.add('datatype-date-parse', function (Y, NAME) {","","/**"," * Parse number submodule."," *"," * @module datatype-date"," * @submodule datatype-date-parse"," * @for Date"," */","var LANG = Y.Lang;","","Y.mix(Y.namespace(\"Date\"), {"," /**"," * Converts data to type Date."," *"," * @method parse"," * @param data {String | Number} Data to convert. Values supported by the Date constructor are supported."," * @return {Date} A Date, or null."," */"," parse: function(data) {"," var date = null;",""," //Convert to date"," if(!(LANG.isDate(data))) {"," date = new Date(data);"," }"," else {"," return date;"," }",""," // Validate"," if(LANG.isDate(date) && (date != \"Invalid Date\") && !isNaN(date)) { // Workaround for bug 2527965"," return date;"," }"," else {"," return null;"," }"," }","});","","// Add Parsers shortcut","Y.namespace(\"Parsers\").date = Y.Date.parse;","","Y.namespace(\"DataType\");","Y.DataType.Date = Y.Date;","","","}, '@VERSION@');"];
-_yuitest_coverage["build/datatype-date-parse/datatype-date-parse.js"].lines = {"1":0,"10":0,"12":0,"21":0,"24":0,"25":0,"28":0,"32":0,"33":0,"36":0,"42":0,"44":0,"45":0};
-_yuitest_coverage["build/datatype-date-parse/datatype-date-parse.js"].functions = {"parse:20":0,"(anonymous 1):1":0};
-_yuitest_coverage["build/datatype-date-parse/datatype-date-parse.js"].coveredLines = 13;
+_yuitest_coverage["build/datatype-date-parse/datatype-date-parse.js"].code=["YUI.add('datatype-date-parse', function (Y, NAME) {","","/**"," * Parse number submodule."," *"," * @module datatype-date"," * @submodule datatype-date-parse"," * @for Date"," */","Y.mix(Y.namespace(\"Date\"), {"," /**"," * Converts data to type Date."," *"," * @method parse"," * @param data {Date|Number|String} date object, timestamp (string or number), or string parsable by Date.parse"," * @return {Date} a Date object or null if unable to parse"," */"," parse: function(data) {"," var val = new Date(+data || data);"," if (Y.Lang.isDate(val)) {"," return val;"," } else {"," return null;"," }"," }","});","","// Add Parsers shortcut","Y.namespace(\"Parsers\").date = Y.Date.parse;","","Y.namespace(\"DataType\");","Y.DataType.Date = Y.Date;","","","}, '@VERSION@');"];
+_yuitest_coverage["build/datatype-date-parse/datatype-date-parse.js"].lines = {"1":0,"10":0,"19":0,"20":0,"21":0,"23":0,"29":0,"31":0,"32":0};
+_yuitest_coverage["build/datatype-date-parse/datatype-date-parse.js"].functions = {"parse:18":0,"(anonymous 1):1":0};
+_yuitest_coverage["build/datatype-date-parse/datatype-date-parse.js"].coveredLines = 9;
_yuitest_coverage["build/datatype-date-parse/datatype-date-parse.js"].coveredFunctions = 2;
_yuitest_coverline("build/datatype-date-parse/datatype-date-parse.js", 1);
YUI.add('datatype-date-parse', function (Y, NAME) {
@@ -43,53 +43,36 @@ YUI.add('datatype-date-parse', function (Y, NAME) {
*/
_yuitest_coverfunc("build/datatype-date-parse/datatype-date-parse.js", "(anonymous 1)", 1);
_yuitest_coverline("build/datatype-date-parse/datatype-date-parse.js", 10);
-var LANG = Y.Lang;
-
-_yuitest_coverline("build/datatype-date-parse/datatype-date-parse.js", 12);
Y.mix(Y.namespace("Date"), {
/**
* Converts data to type Date.
*
* @method parse
- * @param data {String | Number} Data to convert. Values supported by the Date constructor are supported.
- * @return {Date} A Date, or null.
+ * @param data {Date|Number|String} date object, timestamp (string or number), or string parsable by Date.parse
+ * @return {Date} a Date object or null if unable to parse
*/
parse: function(data) {
- _yuitest_coverfunc("build/datatype-date-parse/datatype-date-parse.js", "parse", 20);
-_yuitest_coverline("build/datatype-date-parse/datatype-date-parse.js", 21);
-var date = null;
-
- //Convert to date
- _yuitest_coverline("build/datatype-date-parse/datatype-date-parse.js", 24);
-if(!(LANG.isDate(data))) {
- _yuitest_coverline("build/datatype-date-parse/datatype-date-parse.js", 25);
-date = new Date(data);
- }
- else {
- _yuitest_coverline("build/datatype-date-parse/datatype-date-parse.js", 28);
-return date;
- }
-
- // Validate
- _yuitest_coverline("build/datatype-date-parse/datatype-date-parse.js", 32);
-if(LANG.isDate(date) && (date != "Invalid Date") && !isNaN(date)) { // Workaround for bug 2527965
- _yuitest_coverline("build/datatype-date-parse/datatype-date-parse.js", 33);
-return date;
- }
- else {
- _yuitest_coverline("build/datatype-date-parse/datatype-date-parse.js", 36);
+ _yuitest_coverfunc("build/datatype-date-parse/datatype-date-parse.js", "parse", 18);
+_yuitest_coverline("build/datatype-date-parse/datatype-date-parse.js", 19);
+var val = new Date(+data || data);
+ _yuitest_coverline("build/datatype-date-parse/datatype-date-parse.js", 20);
+if (Y.Lang.isDate(val)) {
+ _yuitest_coverline("build/datatype-date-parse/datatype-date-parse.js", 21);
+return val;
+ } else {
+ _yuitest_coverline("build/datatype-date-parse/datatype-date-parse.js", 23);
return null;
}
}
});
// Add Parsers shortcut
-_yuitest_coverline("build/datatype-date-parse/datatype-date-parse.js", 42);
+_yuitest_coverline("build/datatype-date-parse/datatype-date-parse.js", 29);
Y.namespace("Parsers").date = Y.Date.parse;
-_yuitest_coverline("build/datatype-date-parse/datatype-date-parse.js", 44);
+_yuitest_coverline("build/datatype-date-parse/datatype-date-parse.js", 31);
Y.namespace("DataType");
-_yuitest_coverline("build/datatype-date-parse/datatype-date-parse.js", 45);
+_yuitest_coverline("build/datatype-date-parse/datatype-date-parse.js", 32);
Y.DataType.Date = Y.Date;
View
27 build/datatype-date-parse/datatype-date-parse-debug.js
@@ -7,33 +7,20 @@ YUI.add('datatype-date-parse', function (Y, NAME) {
* @submodule datatype-date-parse
* @for Date
*/
-var LANG = Y.Lang;
-
Y.mix(Y.namespace("Date"), {
/**
* Converts data to type Date.
*
* @method parse
- * @param data {String | Number} Data to convert. Values supported by the Date constructor are supported.
- * @return {Date} A Date, or null.
+ * @param data {Date|Number|String} date object, timestamp (string or number), or string parsable by Date.parse
+ * @return {Date} a Date object or null if unable to parse
*/
parse: function(data) {
- var date = null;
-
- //Convert to date
- if(!(LANG.isDate(data))) {
- date = new Date(data);
- }
- else {
- return date;
- }
-
- // Validate
- if(LANG.isDate(date) && (date != "Invalid Date") && !isNaN(date)) { // Workaround for bug 2527965
- return date;
- }
- else {
- Y.log("Could not convert data to type Date", "warn", "date");
+ var val = new Date(+data || data);
+ if (Y.Lang.isDate(val)) {
+ return val;
+ } else {
+ Y.log("Could not convert data " + Y.dump(val) + " to type Date", "warn", "date");
return null;
}
}
View
2  build/datatype-date-parse/datatype-date-parse-min.js
@@ -1 +1 @@
-YUI.add("datatype-date-parse",function(e,t){var n=e.Lang;e.mix(e.namespace("Date"),{parse:function(e){var t=null;return n.isDate(e)?t:(t=new Date(e),n.isDate(t)&&t!="Invalid Date"&&!isNaN(t)?t:null)}}),e.namespace("Parsers").date=e.Date.parse,e.namespace("DataType"),e.DataType.Date=e.Date},"@VERSION@");
+YUI.add("datatype-date-parse",function(e,t){e.mix(e.namespace("Date"),{parse:function(t){var n=new Date(+t||t);return e.Lang.isDate(n)?n:null}}),e.namespace("Parsers").date=e.Date.parse,e.namespace("DataType"),e.DataType.Date=e.Date},"@VERSION@");
View
25 build/datatype-date-parse/datatype-date-parse.js
@@ -7,32 +7,19 @@ YUI.add('datatype-date-parse', function (Y, NAME) {
* @submodule datatype-date-parse
* @for Date
*/
-var LANG = Y.Lang;
-
Y.mix(Y.namespace("Date"), {
/**
* Converts data to type Date.
*
* @method parse
- * @param data {String | Number} Data to convert. Values supported by the Date constructor are supported.
- * @return {Date} A Date, or null.
+ * @param data {Date|Number|String} date object, timestamp (string or number), or string parsable by Date.parse
+ * @return {Date} a Date object or null if unable to parse
*/
parse: function(data) {
- var date = null;
-
- //Convert to date
- if(!(LANG.isDate(data))) {
- date = new Date(data);
- }
- else {
- return date;
- }
-
- // Validate
- if(LANG.isDate(date) && (date != "Invalid Date") && !isNaN(date)) { // Workaround for bug 2527965
- return date;
- }
- else {
+ var val = new Date(+data || data);
+ if (Y.Lang.isDate(val)) {
+ return val;
+ } else {
return null;
}
}
View
27 src/date/js/date-parse.js
@@ -5,33 +5,20 @@
* @submodule datatype-date-parse
* @for Date
*/
-var LANG = Y.Lang;
-
Y.mix(Y.namespace("Date"), {
/**
* Converts data to type Date.
*
* @method parse
- * @param data {String | Number} Data to convert. Values supported by the Date constructor are supported.
- * @return {Date} A Date, or null.
+ * @param data {Date|Number|String} date object, timestamp (string or number), or string parsable by Date.parse
+ * @return {Date} a Date object or null if unable to parse
*/
parse: function(data) {
- var date = null;
-
- //Convert to date
- if(!(LANG.isDate(data))) {
- date = new Date(data);
- }
- else {
- return date;
- }
-
- // Validate
- if(LANG.isDate(date) && (date != "Invalid Date") && !isNaN(date)) { // Workaround for bug 2527965
- return date;
- }
- else {
- Y.log("Could not convert data to type Date", "warn", "date");
+ var val = new Date(+data || data);
+ if (Y.Lang.isDate(val)) {
+ return val;
+ } else {
+ Y.log("Could not convert data " + Y.dump(val) + " to type Date", "warn", "date");
return null;
}
}
View
48 src/date/tests/unit/assets/date-tests.js
@@ -1,7 +1,5 @@
YUI.add('date-tests', function(Y) {
-
-
//Helper function to normalize timezone dependent hours.
var getHours = function(date, pad) {
pad = (pad === false) ? false : true;
@@ -15,18 +13,14 @@ YUI.add('date-tests', function(Y) {
if (h < 10 & pad) {
h = '0' + h;
}
- return h;
+ return h;
};
-
-
-
// Set up the page
var LANG = Y.Lang,
ASSERT = Y.Assert,
ARRAYASSERT = Y.ArrayAssert;
-
var testParse = new Y.Test.Case({
name: "Date Parse Tests",
@@ -41,17 +35,26 @@ YUI.add('date-tests', function(Y) {
},
testParse: function() {
- var date = Y.Date.parse("December 17, 1995 03:24:00");
- ASSERT.isTrue(LANG.isDate(date), "Expected date.");
-
- date = Y.Date.parse(1995,11,17);
- ASSERT.isTrue(LANG.isDate(date), "Expected date.");
-
- date = Y.Date.parse(1995,11,17,3,24,0);
- ASSERT.isTrue(LANG.isDate(date), "Expected date.");
-
- date = Y.Date.parse(948548583);
- ASSERT.isTrue(LANG.isDate(date), "Expected date.");
+ var date, parsed;
+
+ date = new Date("December 17, 1995 03:24:00");
+ parsed = Y.Date.parse("December 17, 1995 03:24:00");
+ ASSERT.isTrue(LANG.isDate(parsed), "Parsing date string. Expected date.");
+ ASSERT.areEqual(+date, +parsed, "Parsing date string. Dates should have matched.");
+
+ date = new Date();
+ parsed = Y.Date.parse(date);
+ ASSERT.isTrue(LANG.isDate(parsed), "Parsing date object. Expected date.");
+ ASSERT.areEqual(+date, +parsed, "Parsing date object. Dates should have matched.");
+
+ date = new Date(819199440000);
+ parsed = Y.Date.parse(819199440000);
+ ASSERT.isTrue(LANG.isDate(parsed), "Parsing numeric timestamp. Expected date.");
+ ASSERT.areEqual(+date, +parsed, "Parsing numeric timestamp. Dates should have matched.");
+
+ parsed = Y.Date.parse('819199440000');
+ ASSERT.isTrue(LANG.isDate(parsed), "Parsing string timestamp. Expected date.");
+ ASSERT.areEqual(+date, +parsed, "Parsing string timestamp. Dates should have matched.");
}
});
@@ -71,7 +74,7 @@ YUI.add('date-tests', function(Y) {
testFormats: function() {
var date = new Date(819199440000),
output;
-
+
//Must set this here because other tests are "resetting" the default lang.
Y.Intl.setLang("datatype-date-format", "en-US");
@@ -117,7 +120,7 @@ YUI.add('date-tests', function(Y) {
ASSERT.areSame(50, parseInt(output, 10), 'Expected %W format.');
output = Y.Date.format(date, {format:"%Z"});
- var tz = date.toString().replace(/^.*:\d\d( GMT[+-]\d+)? \(?([A-Za-z ]+)\)?\d*$/, "$2").replace(/[a-z ]/g, "");
+ var tz = date.toString().replace(/^.*:\d\d( GMT[+-]\d+)? \(?([A-Za-z ]+)\)?\d*$/, "$2").replace(/[a-z ]/g, "");
ASSERT.areSame(tz, output, 'Expected %Z format.');
output = Y.Date.format(date, {format:"%"});
@@ -220,7 +223,7 @@ YUI.add('date-tests', function(Y) {
name: "Date Format Punjabi Tests",
testPunjabi: function() {
-
+
// provide data in Punjabi for India
Y.Intl.add("datatype-date-format", "pa-IN", {
"a":["ਐਤ.","ਸੋਮ.","ਮੰਗਲ.","ਬੁਧ.","ਵੀਰ.","ਸ਼ੁਕਰ.","ਸ਼ਨੀ."],
@@ -278,9 +281,6 @@ YUI.add('date-tests', function(Y) {
}
});
-
-
-
var suite = new Y.Test.Suite("Date");
suite.add(testParse);
suite.add(testFormatUS);
Something went wrong with that request. Please try again.