Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions dist/Jsonix-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,7 @@ Jsonix.XML.QName.key = function(namespaceURI, localPart) {
Jsonix.Util.Ensure.ensureString(localPart);
if (namespaceURI) {
var colonPosition = localPart.indexOf(':');
var localName;
if (colonPosition > 0 && colonPosition < localPart.length) {
localName = localPart.substring(colonPosition + 1);
} else {
Expand Down Expand Up @@ -4901,7 +4902,7 @@ Jsonix.Schema.XSD.Calendar = Jsonix.Class(Jsonix.Schema.XSD.AnySimpleType, {
};
return new Jsonix.XML.Calendar(data);
}
throw new Error('Value [' + value + '] does not match the xs:date pattern.');
throw new Error('Value [' + text + '] does not match the xs:date pattern.');
},
parseDate : function(text, context, input, scope) {
Jsonix.Util.Ensure.ensureString(text);
Expand All @@ -4916,7 +4917,7 @@ Jsonix.Schema.XSD.Calendar = Jsonix.Class(Jsonix.Schema.XSD.AnySimpleType, {
};
return new Jsonix.XML.Calendar(data);
}
throw new Error('Value [' + value + '] does not match the xs:date pattern.');
throw new Error('Value [' + text + '] does not match the xs:date pattern.');
},
parseTime : function(text, context, input, scope) {
Jsonix.Util.Ensure.ensureString(text);
Expand All @@ -4932,7 +4933,7 @@ Jsonix.Schema.XSD.Calendar = Jsonix.Class(Jsonix.Schema.XSD.AnySimpleType, {
};
return new Jsonix.XML.Calendar(data);
}
throw new Error('Value [' + value + '] does not match the xs:time pattern.');
throw new Error('Value [' + text + '] does not match the xs:time pattern.');
},
parseTimezoneString : function(text) {
// (('+' | '-') hh ':' mm) | 'Z'
Expand All @@ -4955,7 +4956,7 @@ Jsonix.Schema.XSD.Calendar = Jsonix.Class(Jsonix.Schema.XSD.AnySimpleType, {
var minute = parseInt(results[5], 10);
return sign * (hour * 60 + minute);
}
throw new Error('Value [' + value + '] does not match the timezone pattern.');
throw new Error('Value [' + text + '] does not match the timezone pattern.');
}
},
print : function(value, context, output, scope) {
Expand Down
19 changes: 10 additions & 9 deletions dist/Jsonix-min.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,11 +331,12 @@ return new Jsonix.XML.QName(e,f,g)
Jsonix.XML.QName.fromObjectOrString=function(f,d,e){if(Jsonix.Util.Type.isString(f)){return Jsonix.XML.QName.fromString(f,d,e)
}else{return Jsonix.XML.QName.fromObject(f)
}};
Jsonix.XML.QName.key=function(f,e){Jsonix.Util.Ensure.ensureString(e);
if(f){var d=e.indexOf(":");
if(d>0&&d<e.length){localName=e.substring(d+1)
}else{localName=e
}return"{"+f+"}"+localName
Jsonix.XML.QName.key=function(g,e){Jsonix.Util.Ensure.ensureString(e);
if(g){var h=e.indexOf(":");
var f;
if(h>0&&h<e.length){f=e.substring(h+1)
}else{f=e
}return"{"+g+"}"+f
}else{return e
}};
Jsonix.XML.Calendar=Jsonix.Class({year:NaN,month:NaN,day:NaN,hour:NaN,minute:NaN,second:NaN,fractionalSecond:NaN,timezone:NaN,date:null,initialize:function(f){Jsonix.Util.Ensure.ensureObject(f);
Expand Down Expand Up @@ -1939,19 +1940,19 @@ var k=new RegExp("^"+Jsonix.Schema.XSD.Calendar.DATETIME_PATTERN+"$");
var h=j.match(k);
if(h!==null){var l={year:parseInt(h[1],10),month:parseInt(h[5],10),day:parseInt(h[7],10),hour:parseInt(h[9],10),minute:parseInt(h[10],10),second:parseInt(h[11],10),fractionalSecond:(h[12]?parseFloat(h[12]):0),timezone:this.parseTimezoneString(h[14])};
return new Jsonix.XML.Calendar(l)
}throw new Error("Value ["+value+"] does not match the xs:date pattern.")
}throw new Error("Value ["+j+"] does not match the xs:date pattern.")
},parseDate:function(j,n,i,m){Jsonix.Util.Ensure.ensureString(j);
var k=new RegExp("^"+Jsonix.Schema.XSD.Calendar.DATE_PATTERN+"$");
var h=j.match(k);
if(h!==null){var l={year:parseInt(h[1],10),month:parseInt(h[5],10),day:parseInt(h[7],10),timezone:this.parseTimezoneString(h[9])};
return new Jsonix.XML.Calendar(l)
}throw new Error("Value ["+value+"] does not match the xs:date pattern.")
}throw new Error("Value ["+j+"] does not match the xs:date pattern.")
},parseTime:function(j,n,i,m){Jsonix.Util.Ensure.ensureString(j);
var k=new RegExp("^"+Jsonix.Schema.XSD.Calendar.TIME_PATTERN+"$");
var h=j.match(k);
if(h!==null){var l={hour:parseInt(h[1],10),minute:parseInt(h[2],10),second:parseInt(h[3],10),fractionalSecond:(h[4]?parseFloat(h[4]):0),timezone:this.parseTimezoneString(h[6])};
return new Jsonix.XML.Calendar(l)
}throw new Error("Value ["+value+"] does not match the xs:time pattern.")
}throw new Error("Value ["+j+"] does not match the xs:time pattern.")
},parseTimezoneString:function(i){if(!Jsonix.Util.Type.isString(i)){return NaN
}else{if(i===""){return NaN
}else{if(i==="Z"){return 0
Expand All @@ -1963,7 +1964,7 @@ if(l!==null){var g=l[1]==="+"?1:-1;
var h=parseInt(l[4],10);
var k=parseInt(l[5],10);
return g*(h*60+k)
}throw new Error("Value ["+value+"] does not match the timezone pattern.")
}throw new Error("Value ["+i+"] does not match the timezone pattern.")
}}}}}},print:function(g,e,f,h){Jsonix.Util.Ensure.ensureObject(g);
if(Jsonix.Util.NumberUtils.isInteger(g.year)&&Jsonix.Util.NumberUtils.isInteger(g.month)&&Jsonix.Util.NumberUtils.isInteger(g.day)&&Jsonix.Util.NumberUtils.isInteger(g.hour)&&Jsonix.Util.NumberUtils.isInteger(g.minute)&&Jsonix.Util.NumberUtils.isInteger(g.second)){return this.printDateTime(g)
}else{if(Jsonix.Util.NumberUtils.isInteger(g.year)&&Jsonix.Util.NumberUtils.isInteger(g.month)&&Jsonix.Util.NumberUtils.isInteger(g.day)){return this.printDate(g)
Expand Down
9 changes: 5 additions & 4 deletions nodejs/scripts/jsonix.js
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,7 @@ Jsonix.XML.QName.key = function(namespaceURI, localPart) {
Jsonix.Util.Ensure.ensureString(localPart);
if (namespaceURI) {
var colonPosition = localPart.indexOf(':');
var localName;
if (colonPosition > 0 && colonPosition < localPart.length) {
localName = localPart.substring(colonPosition + 1);
} else {
Expand Down Expand Up @@ -4901,7 +4902,7 @@ Jsonix.Schema.XSD.Calendar = Jsonix.Class(Jsonix.Schema.XSD.AnySimpleType, {
};
return new Jsonix.XML.Calendar(data);
}
throw new Error('Value [' + value + '] does not match the xs:date pattern.');
throw new Error('Value [' + text + '] does not match the xs:date pattern.');
},
parseDate : function(text, context, input, scope) {
Jsonix.Util.Ensure.ensureString(text);
Expand All @@ -4916,7 +4917,7 @@ Jsonix.Schema.XSD.Calendar = Jsonix.Class(Jsonix.Schema.XSD.AnySimpleType, {
};
return new Jsonix.XML.Calendar(data);
}
throw new Error('Value [' + value + '] does not match the xs:date pattern.');
throw new Error('Value [' + text + '] does not match the xs:date pattern.');
},
parseTime : function(text, context, input, scope) {
Jsonix.Util.Ensure.ensureString(text);
Expand All @@ -4932,7 +4933,7 @@ Jsonix.Schema.XSD.Calendar = Jsonix.Class(Jsonix.Schema.XSD.AnySimpleType, {
};
return new Jsonix.XML.Calendar(data);
}
throw new Error('Value [' + value + '] does not match the xs:time pattern.');
throw new Error('Value [' + text + '] does not match the xs:time pattern.');
},
parseTimezoneString : function(text) {
// (('+' | '-') hh ':' mm) | 'Z'
Expand All @@ -4955,7 +4956,7 @@ Jsonix.Schema.XSD.Calendar = Jsonix.Class(Jsonix.Schema.XSD.AnySimpleType, {
var minute = parseInt(results[5], 10);
return sign * (hour * 60 + minute);
}
throw new Error('Value [' + value + '] does not match the timezone pattern.');
throw new Error('Value [' + text + '] does not match the timezone pattern.');
}
},
print : function(value, context, output, scope) {
Expand Down
40 changes: 40 additions & 0 deletions nodejs/scripts/tests/xsd.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,46 @@ module.exports =
test.equal(-733, gd.timezone);
test.equal('---06-12:13', Jsonix.Schema.XSD.Calendar.INSTANCE.print(gd));

test.throws(
function() { Jsonix.Schema.XSD.Calendar.INSTANCE.parse('nomatch'); },
/Value \[nomatch\] does not match xs:dateTime, xs:date, xs:time, xs:gYearMonth, xs:gYear, xs:gMonthDay, xs:gMonth or xs:gDay patterns\./);

test.throws(
function() { Jsonix.Schema.XSD.Calendar.INSTANCE.parseGYearMonth('201002'); },
/Value \[201002\] does not match the xs:gYearMonth pattern\./);

test.throws(
function() { Jsonix.Schema.XSD.Calendar.INSTANCE.parseGYear('10'); },
/Value \[10\] does not match the xs:gYear pattern\./);

test.throws(
function() { Jsonix.Schema.XSD.Calendar.INSTANCE.parseGMonthDay('02-10'); },
/Value \[02-10\] does not match the xs:gMonthDay pattern\./);

test.throws(
function() { Jsonix.Schema.XSD.Calendar.INSTANCE.parseGMonth('02'); },
/Value \[02\] does not match the xs:gMonth pattern\./);

test.throws(
function() { Jsonix.Schema.XSD.Calendar.INSTANCE.parseGDay('01'); },
/Value \[01\] does not match the xs:gDay pattern\./);

test.throws(
function() { Jsonix.Schema.XSD.Calendar.INSTANCE.parseDateTime('2010-02-01 12:23:0'); },
/Value \[2010-02-01 12:23:0\] does not match the xs:date pattern\./);

test.throws(
function() { Jsonix.Schema.XSD.Calendar.INSTANCE.parseDate('20100201'); },
/Value \[20100201\] does not match the xs:date pattern\./);

test.throws(
function() { Jsonix.Schema.XSD.Calendar.INSTANCE.parseTime('12:23:0'); },
/Value \[12:23:0\] does not match the xs:time pattern\./);

test.throws(
function() { Jsonix.Schema.XSD.Calendar.INSTANCE.parseTimezoneString('PDT'); },
/Value \[PDT\] does not match the timezone pattern\./);

test.done();
},

Expand Down
2 changes: 1 addition & 1 deletion nodejs/tests/ar/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion nodejs/tests/basic/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion nodejs/tests/browserify/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion nodejs/tests/po/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion nodejs/tests/wps/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Jsonix.Schema.XSD.Calendar = Jsonix.Class(Jsonix.Schema.XSD.AnySimpleType, {
};
return new Jsonix.XML.Calendar(data);
}
throw new Error('Value [' + value + '] does not match the xs:date pattern.');
throw new Error('Value [' + text + '] does not match the xs:date pattern.');
},
parseDate : function(text, context, input, scope) {
Jsonix.Util.Ensure.ensureString(text);
Expand All @@ -117,7 +117,7 @@ Jsonix.Schema.XSD.Calendar = Jsonix.Class(Jsonix.Schema.XSD.AnySimpleType, {
};
return new Jsonix.XML.Calendar(data);
}
throw new Error('Value [' + value + '] does not match the xs:date pattern.');
throw new Error('Value [' + text + '] does not match the xs:date pattern.');
},
parseTime : function(text, context, input, scope) {
Jsonix.Util.Ensure.ensureString(text);
Expand All @@ -133,7 +133,7 @@ Jsonix.Schema.XSD.Calendar = Jsonix.Class(Jsonix.Schema.XSD.AnySimpleType, {
};
return new Jsonix.XML.Calendar(data);
}
throw new Error('Value [' + value + '] does not match the xs:time pattern.');
throw new Error('Value [' + text + '] does not match the xs:time pattern.');
},
parseTimezoneString : function(text) {
// (('+' | '-') hh ':' mm) | 'Z'
Expand All @@ -156,7 +156,7 @@ Jsonix.Schema.XSD.Calendar = Jsonix.Class(Jsonix.Schema.XSD.AnySimpleType, {
var minute = parseInt(results[5], 10);
return sign * (hour * 60 + minute);
}
throw new Error('Value [' + value + '] does not match the timezone pattern.');
throw new Error('Value [' + text + '] does not match the timezone pattern.');
}
},
print : function(value, context, output, scope) {
Expand Down