Skip to content

Commit 2baa6f8

Browse files
committed
Issue #73. Updated the tests to match latest fixes.
1 parent 6697cd9 commit 2baa6f8

File tree

8 files changed

+13
-21
lines changed

8 files changed

+13
-21
lines changed

nodejs/scripts/jsonix.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,7 +1010,6 @@ Jsonix.XML.Calendar = Jsonix.Class({
10101010
} else {
10111011
this.timezone = NaN;
10121012
}
1013-
10141013
var initialDate = new Date(0);
10151014
initialDate.setUTCFullYear(this.year || 1970);
10161015
initialDate.setUTCMonth(this.month - 1 || 0);
@@ -1019,7 +1018,7 @@ Jsonix.XML.Calendar = Jsonix.Class({
10191018
initialDate.setUTCMinutes(this.minute || 0);
10201019
initialDate.setUTCSeconds(this.second || 0);
10211020
initialDate.setUTCMilliseconds((this.fractionalSecond || 0) * 1000);
1022-
var timezoneOffset = -60000 * (this.timezoneOffset || 0);
1021+
var timezoneOffset = -60000 * (this.timezone || 0);
10231022
this.date = new Date(initialDate.getTime() + timezoneOffset);
10241023
},
10251024
CLASS_NAME : "Jsonix.XML.Calendar"
@@ -5447,7 +5446,6 @@ Jsonix.Schema.XSD.GYearMonth = Jsonix.Class(Jsonix.Schema.XSD.Calendar, {
54475446
if (value instanceof Date) {
54485447
year = value.getFullYear();
54495448
month = value.getMonth() + 1;
5450-
timezone = value.getTimezoneOffset() * -1;
54515449
} else {
54525450
Jsonix.Util.Ensure.ensureInteger(value.year);
54535451
year = value.year;
@@ -5488,7 +5486,6 @@ Jsonix.Schema.XSD.GYear = Jsonix.Class(Jsonix.Schema.XSD.Calendar, {
54885486

54895487
if (value instanceof Date) {
54905488
year = value.getFullYear();
5491-
timezone = value.getTimezoneOffset() * -1;
54925489
} else {
54935490
Jsonix.Util.Ensure.ensureInteger(value.year);
54945491
year = value.year;
@@ -5530,7 +5527,6 @@ Jsonix.Schema.XSD.GMonthDay = Jsonix.Class(Jsonix.Schema.XSD.Calendar, {
55305527
if (value instanceof Date) {
55315528
month = value.getMonth() + 1;
55325529
day = value.getDate();
5533-
timezone = value.getTimezoneOffset() * -1;
55345530
} else {
55355531
Jsonix.Util.Ensure.ensureInteger(value.month);
55365532
Jsonix.Util.Ensure.ensureInteger(value.day);
@@ -5570,7 +5566,6 @@ Jsonix.Schema.XSD.GDay = Jsonix.Class(Jsonix.Schema.XSD.Calendar, {
55705566

55715567
if (value instanceof Date) {
55725568
day = value.getDate();
5573-
timezone = value.getTimezoneOffset() * -1;
55745569
} else {
55755570
Jsonix.Util.Ensure.ensureInteger(value.day);
55765571
day = value.day;
@@ -5609,7 +5604,6 @@ Jsonix.Schema.XSD.GMonth = Jsonix.Class(Jsonix.Schema.XSD.Calendar, {
56095604

56105605
if (value instanceof Date) {
56115606
month = value.getMonth() + 1;
5612-
timezone = value.getTimezoneOffset() * -1;
56135607
} else {
56145608
Jsonix.Util.Ensure.ensureInteger(value.month);
56155609
month = value.month;

nodejs/scripts/tests/GH73/GH73Core.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ module.exports = {
1818
test.equal(-300, unmarshaller.unmarshalString('<GDateTypes year="2013-05:00"/>').value.year.timezone);
1919
test.equal(-2013, unmarshaller.unmarshalString('<GDateTypes year="-2013+05:00"/>').value.year.year);
2020
test.equal(300, unmarshaller.unmarshalString('<GDateTypes year="-2013+05:00"/>').value.year.timezone);
21-
// TODO depends on the time zone
22-
// This fails at the moment
23-
test.equal("1970-01-01T00:00:00.000+01:00", unmarshaller.unmarshalString('<GDateTypes year="1970+01:00"/>').value.year.date.toISOString());
21+
test.equal(-60*60000, unmarshaller.unmarshalString('<GDateTypes year="1970+01:00"/>').value.year.date.getTime());
2422

2523
test.throws(function() {
2624
unmarshaller.unmarshalString('<GDateTypes year="0000"/>');

nodejs/scripts/tests/GH73/GH73GDay.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ module.exports = {
4949
var g = Jsonix.Schema.XSD.GDay.INSTANCE;
5050
var gDateType = new Date();
5151
gDateType.setDate(1);
52-
test.equal("---01Z", g.print(gDateType));
52+
test.equal("---01", g.print(gDateType));
5353
test.done();
5454
},
5555

nodejs/scripts/tests/GH73/GH73GMonth.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ module.exports = {
3737
var g = Jsonix.Schema.XSD.GMonth.INSTANCE;
3838
var gDateType = new Date();
3939
gDateType.setMonth(0);
40-
test.equal("--01Z", g.print(gDateType));
40+
test.equal("--01", g.print(gDateType));
4141
test.done();
4242
},
4343

nodejs/scripts/tests/GH73/GH73GMonthDay.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ module.exports = {
3939
var gDateType = new Date();
4040
gDateType.setMonth(0);
4141
gDateType.setDate(1);
42-
test.equal("--01-01Z", g.print(gDateType));
42+
test.equal("--01-01", g.print(gDateType));
4343
test.done();
4444
},
4545

@@ -58,7 +58,7 @@ module.exports = {
5858

5959
test.equal(0, g.parse('--01-01').date.getMonth());
6060
test.equal(1, g.parse('--01-01').date.getDate());
61-
test.equal(0, g.parse('--01-01+05:00').date.getTimezoneOffset());
61+
test.equal(-300 * 60000, g.parse('--01-01+05:00').date.getTime());
6262
test.done();
6363
}
6464
};

nodejs/scripts/tests/GH73/GH73GYear.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,7 @@ module.exports = {
5454
var g = Jsonix.Schema.XSD.GYear.INSTANCE;
5555
var gDateType = new Date();
5656
gDateType.setFullYear(1970);
57-
// FIXME: This depends on the time zone of the environment
58-
// REVIEW tom: see line 3. This works on my ubuntu 14.04
59-
// with nodeunit 0.9.1
60-
test.equal("1970Z", g.print(gDateType));
57+
test.equal("1970", g.print(gDateType));
6158
test.done();
6259
},
6360

nodejs/scripts/tests/GH73/GH73GYearMonth.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ module.exports = {
5454
var gDateType = new Date();
5555
gDateType.setFullYear(1970);
5656
gDateType.setMonth(0);
57-
test.equal("1970-01Z", g.print(gDateType));
57+
test.equal("1970-01", g.print(gDateType));
5858
test.done();
5959
},
6060

@@ -79,7 +79,10 @@ module.exports = {
7979
test.equal(10, g.parse('1967-11').date.getMonth());
8080
test.equal(1967, g.parse('1967-11Z').date.getFullYear());
8181
test.equal(10, g.parse('1967-11Z').date.getMonth());
82-
test.equal(0, g.parse('1967-11+05:00').date.getTimezoneOffset());
82+
test.equal(0, g.parse('1970-01').date.getTime());
83+
test.equal(0, g.parse('1970-01Z').date.getTime());
84+
test.equal(300, g.parse('1970-01+05:00').timezone);
85+
test.equal(-300 * 60000, g.parse('1970-01+05:00').date.getTime());
8386

8487
test.done();
8588
}

nodejs/scripts/tests/xml.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ module.exports =
191191
},
192192
"Date" : function(test) {
193193
test.equal(0, new Jsonix.XML.Calendar({}).date.getTime());
194-
test.equal(34401906700, new Jsonix.XML.Calendar({year:1971,month:2,day:3,hour:4,minute:5,second:6,fractionalSecond:.7,timezone:480}).date.getTime());
194+
test.equal(34401906700 - 480 * 60000, new Jsonix.XML.Calendar({year:1971,month:2,day:3,hour:4,minute:5,second:6,fractionalSecond:.7,timezone:480}).date.getTime());
195195
test.done();
196196
}
197197
}

0 commit comments

Comments
 (0)