desc: date/time api (#977) tests: # Type shims -- see shim.yaml - def: rt1 = 1375147296.6812 - def: t1 = r.epoch_time(rt1) - def: t2 = r.epoch_time(rt1 + 1000) # Arithmetic - cd: (t1 + 1000).to_epoch_time() js: t1.add(1000).toEpochTime() ot: (1375148296.681) - cd: (t1 - 1000).to_epoch_time() js: t1.sub(1000).toEpochTime() ot: (1375146296.681) - cd: (t1 - (t1 - 1000)) js: t1.sub(t1.sub(1000)) ot: 1000 # Comparisons - cd: (t1 < t1) js: t1.lt(t1) ot: false - cd: (t1 <= t1) js: t1.le(t1) ot: true - cd: (t1.eq(t1)) py: (t1 == t1) ot: true - cd: (t1.ne(t1)) py: (t1 != t1) ot: false - cd: (t1 >= t1) js: t1.ge(t1) ot: true - cd: (t1 > t1) js: t1.gt(t1) ot: false - cd: (t1 < t2) js: t1.lt(t2) ot: true - cd: (t1 <= t2) js: t1.le(t2) ot: true - cd: (t1.eq(t2)) py: (t1 == t2) ot: false - cd: (t1.ne(t2)) py: (t1 != t2) ot: true - cd: (t1 >= t2) js: t1.ge(t2) ot: false - cd: (t1 > t2) js: t1.gt(t2) ot: false # Predicates - cd: t1.during(t1, t1 + 1000) js: t1.during(t1, t1.add(1000)) ot: true - rb: t1.during(t1, t1 + 1000, :left_bound => :open) py: t1.during(t1, t1 + 1000, left_bound='open') js: t1.during(t1, t1.add(1000), {leftBound:'open'}) ot: false - cd: t1.during(t1, t1) ot: false - rb: t1.during(t1, t1, :right_bound => :closed) py: t1.during(t1, t1, right_bound='closed') js: t1.during(t1, t1, {rightBound:'closed'}) ot: true # Time Zone Manipulation -- see timezones.yaml # Portion Retrieval - cd: t1.date().to_epoch_time() ot: 1375142400 - cd: t1.time_of_day() ot: (4896.681) - cd: t1.year() ot: 2013 - cd: t1.month() ot: 7 - cd: t1.day() ot: 30 - cd: t1.day_of_week() ot: 2 - cd: t1.day_of_year() ot: 211 - cd: t1.hours() ot: 1 - cd: t1.minutes() ot: 21 - cd: t1.seconds() ot: 36.681 # Construction/Conversion - cd: r.time(2013, r.july, 29, 23, 30, 0.1, "-07:00").to_epoch_time() ot: (1375165800.1) - cd: r.time(2013, r.july, 29, 23, 30, 0.1, "-07:00").timezone() ot: ("-07:00") - cd: r.time(2013, r.july, 29, 23, 30, 0.1).to_epoch_time() ot: err("ReqlQueryLogicError", "Got 6 arguments to TIME (expected 4 or 7).", []) - cd: r.time(2013, r.july, 29, 23, 30, 0.1).timezone() ot: err("ReqlQueryLogicError", "Got 6 arguments to TIME (expected 4 or 7).", []) - cd: r.time(2013, r.july, 29, 23, 30).to_epoch_time() ot: err("ReqlQueryLogicError", "Got 5 arguments to TIME (expected 4 or 7).", []) - cd: r.time(2013, r.july, 29, 23).to_epoch_time() ot: err("ReqlQueryLogicError", "Expected type STRING but found NUMBER.", []) - cd: r.time(2013, r.july, 29, "-07:00").to_epoch_time() ot: 1375081200 - cd: r.time(2013, r.july, 29, "-07:00").timezone() ot: ("-07:00") - cd: r.time(2013, r.july, 29).to_epoch_time() ot: err("ReqlCompileError", "Expected between 4 and 7 arguments but found 3.", []) - cd: r.time(2013, r.july, 29).timezone() ot: err("ReqlCompileError", "Expected between 4 and 7 arguments but found 3.", []) - cd: r.iso8601("2013-07-30T20:56:05-07:00").to_epoch_time() js: r.ISO8601("2013-07-30T20:56:05-07:00").to_epoch_time() ot: 1375242965 - cd: r.epoch_time(1375242965).in_timezone("-07:00").to_iso8601() js: r.epochTime(1375242965).inTimezone("-07:00").toISO8601() ot: ("2013-07-30T20:56:05-07:00") - cd: r.now().type_of() ot: ("PTYPE