// 0000-00-00 0000-W00 or 0000-W00-0 + T + 00 or 00:00 or 00:00:00 or 00:00:00.000 + +00:00 or +0000 or +00)
var extendedIsoRegex = /^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/;
var basicIsoRegex = /^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/;
+var yearIsoRegex = /^\s*(\d{4})$/;
var tzRegex = /Z|[+-]\d\d(?::?\d\d)?/;
// YYYYMM is NOT allowed by the standard
['GGGG[W]WWE', /\d{4}W\d{3}/],
['GGGG[W]WW', /\d{4}W\d{2}/, false],
- ['YYYYDDD', /\d{7}/]
+ ['YYYYDDD', /\d{7}/],
+ ['YYYY', /\d{4}/, false]
];
// iso time formats and regexes
export function configFromISO(config) {
var i, l,
string = config._i,
- match = extendedIsoRegex.exec(string) || basicIsoRegex.exec(string),
+ match = extendedIsoRegex.exec(string) || basicIsoRegex.exec(string) || yearIsoRegex.exec(string),
allowTime, dateFormat, timeFormat, tzFormat;
if (match) {
minute = pad(4 + minOffset),
formats = [
+ ['2011', '2011-01-01T00:00:00.000' + tz],
+ ['2011-10', '2011-10-01T00:00:00.000' + tz],
['2011-10-08', '2011-10-08T00:00:00.000' + tz],
['2011-10-08T18', '2011-10-08T18:00:00.000' + tz],
['2011-10-08T18:04', '2011-10-08T18:04:00.000' + tz],