1
# -*- coding: utf-8 -*-
3
# Copyright 2014 Jaap Karssenberg <jaap.karssenberg@gmail.com>
6
from __future__ import with_statement
12
import zim.datetimetz as datetime
15
class TestDateTimeZ(tests.TestCase):
17
# FIXME would be better to test correctness of results
18
# but first check functions do not give errors
21
with warnings.catch_warnings():
22
warnings.simplefilter("ignore")
32
self.assertTrue(isinstance(s, basestring) and len(s) > 0)
35
self.assertTrue(isinstance(s, basestring) and len(s) > 0)
38
self.assertTrue(isinstance(s, basestring) and len(s) > 0)
41
s = datetime.strftime('%a', dt)
42
self.assertTrue(isinstance(s, basestring) and len(s) > 0)
44
s = datetime.strftime('%%', dt)
45
self.assertEqual(s, '%')
47
s = datetime.strftime('%u', dt)
48
self.assertTrue(isinstance(s, basestring) and len(s) > 0)
50
s = datetime.strftime('%V', dt)
51
self.assertTrue(isinstance(s, basestring) and len(s) > 0)
54
s = datetime.strfcal('%w', dt)
55
self.assertTrue(isinstance(s, basestring) and len(s) > 0)
57
s = datetime.strfcal('%W', dt)
58
self.assertTrue(isinstance(s, basestring) and len(s) > 0)
60
s = datetime.strfcal('%Y', dt)
61
self.assertTrue(isinstance(s, basestring) and len(s) > 0)
63
s = datetime.strfcal('%%', dt)
64
self.assertEqual(s, '%')
67
year, week, weekday = datetime.weekcalendar(dt)
68
self.assertTrue(isinstance(year, int) and 1900 < year and 3000 > year)
69
self.assertTrue(isinstance(week, int) and 1 <= week and 53 >= week)
70
self.assertTrue(isinstance(weekday, int) and 1 <= weekday and 7 >= weekday)
73
start, end = datetime.dates_for_week(year, week)
74
self.assertTrue(isinstance(start, datetime.date))
75
self.assertTrue(isinstance(end, datetime.date))
76
self.assertTrue(start <= dt.date() and end >= dt.date())