.PHONY: test hint test-moment test-lang
test: hint test-moment test-lang
+test-zone:
+ sh ./test/zone.sh
hint:
node_modules/.bin/jshint moment.js
test.equal(a.hours(), 5, 'adding days over DST difference should result in the same hour');
if (b.isDST() && !d.isDST()) {
test.equal(b.hours(), 6, 'adding hours over DST difference should result in a different hour');
+ } else if (!b.isDST() && d.isDST()) {
+ test.equal(b.hours(), 4, 'adding hours over DST difference should result in a different hour');
} else {
test.equal(b.hours(), 5, 'adding hours over DST difference should result in a same hour if the timezone does not have daylight savings time');
}
test.equal(m.date(), 2, "the date should be correct for local");
test.equal(m.day(), 3, "the day should be correct for local");
}
- var zone = (m.zone() > 0) ? Math.floor(m.zone() / 60) : Math.ceil(m.zone() / 60);
+ var zone = (m.zone() > 0) ? Math.ceil(m.zone() / 60) : Math.floor(m.zone() / 60);
var expected = (24 + 3 - zone) % 24;
test.equal(m.hours(), expected, "the hours (" + m.hours() + ") should be correct for local");
test.equal(moment().utc().zone(), 0, "timezone in utc should always be zero");
--- /dev/null
+ZONE=$(systemsetup -gettimezone | sed "s/Time Zone: //g")
+
+names=(Pacific/Pago_Pago Pacific/Honolulu America/Adak Pacific/Apia Pacific/Marquesas Pacific/Gambier America/Anchorage Pacific/Pitcairn America/Los_Angeles America/Santa_Isabel America/Phoenix America/Denver America/Mazatlan America/Guatemala America/Chicago America/Mexico_City America/Bogota Pacific/Easter America/Havana America/New_York America/Caracas America/Santo_Domingo America/Goose_Bay America/Halifax America/St_Johns America/Argentina/Buenos_Aires America/Campo_Grande America/Santiago America/Miquelon America/Godthab America/Asuncion Atlantic/Stanley America/Noronha America/Sao_Paulo America/Montevideo Atlantic/Cape_Verde Atlantic/Azores Africa/Casablanca Europe/London Africa/Lagos Europe/Berlin Asia/Gaza Asia/Beirut Europe/Minsk Europe/Istanbul Asia/Damascus Asia/Jerusalem Africa/Windhoek Africa/Cairo Africa/Johannesburg Asia/Baghdad Europe/Moscow Asia/Tehran Asia/Dubai Asia/Yerevan Asia/Baku Asia/Kabul Asia/Karachi Asia/Yekaterinburg Asia/Kolkata Asia/Kathmandu Asia/Dhaka Asia/Omsk Asia/Rangoon Asia/Jakarta Asia/Krasnoyarsk Asia/Shanghai Asia/Irkutsk Australia/Eucla Asia/Tokyo Asia/Yakutsk Australia/Darwin Australia/Brisbane Asia/Vladivostok Australia/Adelaide Pacific/Noumea Asia/Kamchatka Australia/Lord_Howe Australia/Sydney Pacific/Norfolk Pacific/Tarawa Pacific/Tongatapu Pacific/Fiji Pacific/Auckland Pacific/Chatham Pacific/Kiritimati)
+
+for name in ${names[@]}
+do
+ echo "\n\n\n\n\n\n--- Start tests for $name ---"
+ systemsetup settimezone $name
+ node_modules/.bin/nodeunit ./test/moment ./test/lang --reporter minimal
+ echo "--- End tests ---"
+done
+
+echo "\n\n--- All tests done! Resetting timezone to $ZONE ---"
+systemsetup settimezone $ZONE
\ No newline at end of file