diff options
Diffstat (limited to 'ext/librethinkdbxx/test/upstream/times/timezones.yaml')
-rw-r--r-- | ext/librethinkdbxx/test/upstream/times/timezones.yaml | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/ext/librethinkdbxx/test/upstream/times/timezones.yaml b/ext/librethinkdbxx/test/upstream/times/timezones.yaml new file mode 100644 index 00000000..d32a5674 --- /dev/null +++ b/ext/librethinkdbxx/test/upstream/times/timezones.yaml @@ -0,0 +1,87 @@ +desc: Test basic timezone manipulation +tests: + - def: t1 = r.time(2013, r.july, 29, 23, 30, 0, "+00:00") + + - def: tutc1 = t1.in_timezone("Z") + - def: tutc2 = t1.in_timezone("+00:00") + - def: tutc3 = t1.in_timezone("+00") + - def: tutcs = r.expr([tutc1, tutc2, tutc3]) + + - def: tm1 = t1.in_timezone("-00:59") + - def: tm2 = t1.in_timezone("-01:00") + - def: tm3 = t1.in_timezone("-01:01") + - def: tms = r.expr([tm1, tm2, tm3]) + + - def: tp1 = t1.in_timezone("+00:59") + - def: tp2 = t1.in_timezone("+01:00") + - def: tp3 = t1.in_timezone("+01:01") + - def: tps = r.expr([tp1, tp2, tp3]) + + - def: ts = tutcs.union(tms).union(tps).union([t1]) + + - rb: tutcs.map{|x| [x.timezone, x.day]} + py: tutcs.map(lambda x:[x.timezone(), x.day()]) + js: tutcs.map([r.row.timezone(), r.row.day()]) + ot: ([["+00:00", 29], ["+00:00", 29], ["+00:00", 29]]) + - rb: tms.map{|x| [x.timezone, x.day]} + py: tms.map(lambda x:[x.timezone(), x.day()]) + js: tms.map([r.row.timezone(), r.row.day()]) + ot: ([["-00:59", 29], ["-01:00", 29], ["-01:01", 29]]) + - rb: tps.map{|x| [x.timezone, x.day]} + py: tps.map(lambda x:[x.timezone(), x.day()]) + js: tps.map([r.row.timezone(), r.row.day()]) + ot: ([["+00:59", 30], ["+01:00", 30], ["+01:01", 30]]) + + # They're all the same time, just in different timezones. + + - rb: ts.concat_map{|x| ts.map{|y| x - y}}.distinct + py: ts.concat_map(lambda x:ts.map(lambda y:x - y)).distinct() + js: ts.concatMap(function(x) { return ts.map(function(y) { return x.sub(y); }); }).distinct() + ot: ([0]) + + # Invalid timezones + + - cd: r.now().in_timezone("") + ot: err('ReqlQueryLogicError', 'Timezone `` does not start with `-` or `+`.') + + - cd: r.now().in_timezone("-00") + ot: err('ReqlQueryLogicError', '`-00` is not a valid time offset.') + + - cd: r.now().in_timezone("-00:00") + ot: err('ReqlQueryLogicError', '`-00:00` is not a valid time offset.') + + - cd: r.now().in_timezone("UTC+00") + ot: err('ReqlQueryLogicError', 'Timezone `UTC+00` does not start with `-` or `+`.') + + - cd: r.now().in_timezone("+00:60") + ot: err('ReqlQueryLogicError', 'Minutes out of range in `+00:60`.') + + - cd: r.now().in_timezone("+25:00") + ot: err('ReqlQueryLogicError', 'Hours out of range in `+25:00`.') + + + - cd: r.time(2013, 1, 1, "") + ot: err('ReqlQueryLogicError', 'Timezone `` does not start with `-` or `+`.') + + - cd: r.time(2013, 1, 1, "-00") + ot: err('ReqlQueryLogicError', '`-00` is not a valid time offset.') + + - cd: r.time(2013, 1, 1, "-00:00") + ot: err('ReqlQueryLogicError', '`-00:00` is not a valid time offset.') + + - cd: r.time(2013, 1, 1, "UTC+00") + ot: err('ReqlQueryLogicError', 'Timezone `UTC+00` does not start with `-` or `+`.') + + - cd: r.time(2013, 1, 1, "+00:60") + ot: err('ReqlQueryLogicError', 'Minutes out of range in `+00:60`.') + + - cd: r.time(2013, 1, 1, "+25:00") + ot: err('ReqlQueryLogicError', 'Hours out of range in `+25:00`.') + + - cd: r.epoch_time(1436428422.339).in_timezone('-08:00').date().to_iso8601() + js: r.epoch_time(1436428422.339).in_timezone('-08:00').date().toISO8601() + ot: ("2015-07-08T00:00:00-08:00") + + - cd: r.epoch_time(1436428422.339).in_timezone('-07:00').date().to_iso8601() + js: r.epoch_time(1436428422.339).in_timezone('-07:00').date().toISO8601() + ot: ("2015-07-09T00:00:00-07:00") |