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])

  - def: bad_tzs = ["-00", "-00:00", "", "UTC+00", "+00:60", "+25:00"]

  - def:
      rb:  subrunner = class << bad_tzs; def run(*args); self.map{|x| begin; RethinkDB::RQL.new.expr([x, RethinkDB::RQL.new.now.in_timezone(x)]).run(*args); rescue RethinkDB::RqlRuntimeError => e; nil; end}.select{|x| x != nil}; end; end

  - rb: bad_tzs
    ot: ([])

  - def:
      rb:  subrunner = class << bad_tzs; def run(*args); self.map{|x| begin; RethinkDB::RQL.new.expr([x, RethinkDB::RQL.new.time(2013, 1, 1, x)]).run(*args); rescue RethinkDB::RqlRuntimeError => e; nil; end}.select{|x| x != nil}; end; end

  - rb: bad_tzs
    ot: ([])

