示例#1
0
 def _cmp_date(self, item, dt):
     assert_equal(DateArithmetic.parse(item), dt.strftime("%Y-%m-%d"))
示例#2
0
 def parse(*ymdh):
     return DateArithmetic.parse('ymdh+1', datetime.datetime(*ymdh))
示例#3
0
 def parse(*ymdh):
     return DateArithmetic.parse('ymdh+1', datetime.datetime(*ymdh))
示例#4
0
 def test_daynumber_minus(self):
     daynum = self.now.toordinal() - 1
     assert_equal(DateArithmetic.parse('daynumber-1'), daynum)
示例#5
0
 def test_hour_minus(self):
     hour = "%02d" % ((int(self.now.strftime("%H")) - 1) % 24)
     assert_equal(DateArithmetic.parse('hour-1'), hour)
示例#6
0
 def test_unixtime(self):
     timestamp = int(self.now.timestamp())
     assert_equal(DateArithmetic.parse('unixtime'), timestamp)
示例#7
0
 def test_unixtime_minus(self):
     timestamp = int(self.now.timestamp()) - 99
     assert_equal(DateArithmetic.parse('unixtime-99'), timestamp)
示例#8
0
 def test_unixtime_plus(self):
     timestamp = int(timeutils.to_timestamp(self.now)) + 100
     assert_equal(DateArithmetic.parse('unixtime+100'), timestamp)
示例#9
0
 def test_unixtime_minus(self):
     timestamp = int(timeutils.to_timestamp(self.now)) - 99
     assert_equal(DateArithmetic.parse('unixtime-99'), timestamp)
示例#10
0
 def _cmp_year(self, item, dt):
     assert_equal(DateArithmetic.parse(item), dt.strftime("%Y"))
示例#11
0
 def test_unixtime(self):
     timestamp = int(timeutils.to_timestamp(self.now))
     assert_equal(DateArithmetic.parse('unixtime'), timestamp)
示例#12
0
 def _cmp_month(self, item, dt):
     assert_equal(DateArithmetic.parse(item), dt.strftime("%m"))
示例#13
0
 def _cmp_date(self, item, dt):
     assert_equal(DateArithmetic.parse(item), dt.strftime("%Y-%m-%d"))
示例#14
0
 def parse(*ymdhm):
     return DateArithmetic.parse('ymdhm-1', datetime.datetime(*ymdhm))
示例#15
0
 def _cmp_month(self, item, dt):
     assert_equal(DateArithmetic.parse(item), dt.strftime("%m"))
示例#16
0
 def test_daynumber(self):
     daynum = self.now.toordinal()
     assert_equal(DateArithmetic.parse('daynumber'), daynum)
示例#17
0
 def _cmp_year(self, item, dt):
     assert_equal(DateArithmetic.parse(item), dt.strftime("%Y"))
示例#18
0
 def test_daynumber_minus(self):
     daynum = self.now.toordinal() - 1
     assert_equal(DateArithmetic.parse('daynumber-1'), daynum)
示例#19
0
 def test_unixtime_plus(self):
     timestamp = int(self.now.timestamp()) + 100
     assert_equal(DateArithmetic.parse('unixtime+100'), timestamp)
示例#20
0
 def test_hour(self):
     hour = self.now.strftime("%H")
     assert_equal(DateArithmetic.parse('hour'), hour)
示例#21
0
 def test_daynumber(self):
     daynum = self.now.toordinal()
     assert_equal(DateArithmetic.parse('daynumber'), daynum)
示例#22
0
 def test_hour_minus(self):
     hour = "%02d" % ((int(self.now.strftime("%H")) - 1) % 24)
     assert_equal(DateArithmetic.parse('hour-1'), hour)
示例#23
0
 def test_hour(self):
     hour = self.now.strftime("%H")
     assert_equal(DateArithmetic.parse('hour'), hour)
示例#24
0
 def test_bad_date_format(self):
     assert DateArithmetic.parse('~~') is None
示例#25
0
 def test_bad_date_format(self):
     assert DateArithmetic.parse('~~') is None
示例#26
0
 def test_unixtime(self):
     timestamp = int(timeutils.to_timestamp(self.now))
     assert_equal(DateArithmetic.parse('unixtime'), timestamp)
示例#27
0
 def parse(*ymdhm):
     return DateArithmetic.parse('ymdhm-1', datetime.datetime(*ymdhm))
示例#28
0
 def test_unixtime(self):
     timestamp = int(self.now.timestamp())
     assert_equal(DateArithmetic.parse('unixtime'), timestamp)