equal
deleted
inserted
replaced
|
1 """ |
|
2 Miscellaneous things |
|
3 """ |
|
4 |
|
5 import datetime |
|
6 |
|
7 class Date (object) : |
|
8 """ |
|
9 Handle dates in URLs as datetime objects (with indeterminate time info) in some timezone |
|
10 """ |
|
11 |
|
12 def __init__ (self, tz, date_fmt="%Y-%m-%d") : |
|
13 """ |
|
14 Format/parse dates in the given timezone using the given format |
|
15 """ |
|
16 |
|
17 self.tz = tz |
|
18 self.date_fmt = date_fmt |
|
19 |
|
20 __name__ = "date" |
|
21 |
|
22 def __call__ (self, date_str) : |
|
23 """ |
|
24 Parse the given date string |
|
25 """ |
|
26 |
|
27 return datetime.datetime.strptime(date_str, self.date_fmt).replace(tzinfo=self.tz) |
|
28 |