Permalink
Browse files

Allow timezone argument to date:calendar so that tests run in any tim…

…ezone
  • Loading branch information...
birchb1024 committed Mar 24, 2018
1 parent 74d0558 commit 0b61866760f309e986172fa4fc70f2d85b3b9c23
Showing with 5 additions and 5 deletions.
  1. +1 −1 src/org/genyris/datetime/DetailedDateTimeFunction.java
  2. +4 −4 test/acceptance/test-time.g
@@ -25,7 +25,7 @@ public Exp bindAndExecute(Closure proc, Exp[] arguments, Environment env) throws
TimeZone tz;
checkMinArguments(arguments, 1);
if (arguments.length == 2) {
tz = TimeZone.getTimeZone(arguments[2].toString());
tz = TimeZone.getTimeZone(arguments[1].toString());
} else {
tz = TimeZone.getDefault();
}
@@ -3,16 +3,16 @@
#
@prefix date "http://www.genyris.org/lang/date#"
var epoch (dict (.am-pm = ^am) (.day-of-month = 1) (.day-of-week = 5) (.day-of-week-in-month = 1) (.day-of-year = 1) (.dst-offset = 0) (.era = ^AD) (.hour = 10) (.hour-of-day = 10) (.leap-year = nil) (.millisecond = 0) (.minute = 0) (.month = 0) (.second = 0) (.week-of-month = 1) (.week-of-year = 1) (.year = 1970) (.zone-offset = 10)) # Calendar Dictionary
assert
var epoch (dict (.am-pm = ^am) (.day-of-month = 1) (.day-of-week = 5) (.day-of-week-in-month = 1) (.day-of-year = 1) (.dst-offset = 0) (.era = ^AD) (.hour = 0) (.hour-of-day = 0) (.leap-year = nil) (.millisecond = 0) (.minute = 0) (.month = 0) (.second = 0) (.week-of-month = 1) (.week-of-year = 1) (.year = 1970) (.zone-offset = 0)) # Calendar Dictionary
assert
equal?
"%s" (.format (calendar 0))
"%s" (.format (date:calendar 0 'GMT'))
"%s" (.format epoch)
var expected (dict (.am-pm = ^pm) (.day-of-month = 8) (.day-of-week = 6) (.day-of-week-in-month = 2) (.day-of-year = 281) (.dst-offset = 3600000) (.era = ^AD) (.hour = 10) (.hour-of-day = 22) (.leap-year = ^nil) (.millisecond = 381) (.minute = 41) (.month = 9) (.second = 43) (.week-of-month = 2) (.week-of-year = 41) (.year = 2010) (.zone-offset = 10))
assert
equal?
"%s" (.format (calendar 1286538103381))
"%s" (.format (date:calendar 1286538103381 "Australia/Melbourne"))
"%s" (.format expected)
assert

0 comments on commit 0b61866

Please sign in to comment.