equal
deleted
inserted
replaced
4 |
4 |
5 import datetime, calendar |
5 import datetime, calendar |
6 |
6 |
7 import qmsk.web.helpers |
7 import qmsk.web.helpers |
8 |
8 |
9 import preferences, urls |
9 import preferences, urls, config |
10 |
10 |
11 class Helpers (qmsk.web.helpers.Helpers) : |
11 class Helpers (qmsk.web.helpers.Helpers) : |
12 """ |
12 """ |
13 Our set of helpers, inheriting from base helpers |
13 Our set of helpers, inheriting from base helpers |
14 """ |
14 """ |
16 def tz_name (self, tz) : |
16 def tz_name (self, tz) : |
17 """ |
17 """ |
18 Returns a string describing the given timezone |
18 Returns a string describing the given timezone |
19 """ |
19 """ |
20 |
20 |
21 return self.now().strftime("%Z%z") |
21 return self.now().strftime(config.TIMEZONE_FMT) |
22 |
22 |
23 def fmt_month (self, date) : |
23 def fmt_month (self, date) : |
24 """ |
24 """ |
25 Formats a month |
25 Formats a month |
26 """ |
26 """ |
27 |
27 |
28 return date.strftime('%B %Y') |
28 return date.strftime(config.MONTH_FMT) |
29 |
29 |
30 def fmt_weekday (self, wday) : |
30 def fmt_weekday (self, wday) : |
31 """ |
31 """ |
32 Formats an abbreviated weekday name |
32 Formats an abbreviated weekday name |
33 """ |
33 """ |
149 """ |
149 """ |
150 Build an UTC timestamp from the given datetime |
150 Build an UTC timestamp from the given datetime |
151 """ |
151 """ |
152 |
152 |
153 return urls.types['ts'].build(dtz) |
153 return urls.types['ts'].build(dtz) |
|
154 |
|
155 def skip_next (self, count, skip) : |
|
156 """ |
|
157 Return skip offset for next page |
|
158 """ |
154 |
159 |
|
160 return count + skip |
|
161 |
|
162 def skip_page (self, count, page) : |
|
163 """ |
|
164 Skip to page |
|
165 """ |
|
166 |
|
167 if page : |
|
168 return count * page |
|
169 |
|
170 else : |
|
171 return None |
|
172 |
|
173 def skip_prev (self, count, skip) : |
|
174 """ |
|
175 Return skip offset for previous page, None for first page |
|
176 """ |
|
177 |
|
178 if skip > count : |
|
179 return skip - count |
|
180 |
|
181 else : |
|
182 return None |
|
183 |
|
184 def max (self, *values) : |
|
185 """ |
|
186 Returns the largest of the given values |
|
187 """ |
|
188 |
|
189 return max(values) |
|
190 |