Skip to content

Commit 39ce8a5

Browse files
author
Alexander Smishlajev
committed
added timezone option (based on patch [SF#1465296])
1 parent 62505e0 commit 39ce8a5

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

roundup/configuration.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Roundup Issue Tracker configuration support
22
#
3-
# $Id: configuration.py,v 1.34 2006-04-27 04:59:37 richard Exp $
3+
# $Id: configuration.py,v 1.35 2006-05-06 17:15:11 a1s Exp $
44
#
55
__docformat__ = "restructuredtext"
66

@@ -12,6 +12,8 @@
1212
import logging, logging.config
1313
import sys
1414

15+
import roundup.date
16+
1517
# XXX i don't think this module needs string translation, does it?
1618

1719
### Exceptions
@@ -407,6 +409,22 @@ class NullableFilePathOption(NullableOption, FilePathOption):
407409
class_description = FilePathOption.class_description
408410
# everything else taken from NullableOption (inheritance order)
409411

412+
class TimezoneOption(Option):
413+
414+
class_description = \
415+
"If pytz module is installed, value may be any valid\n" \
416+
"timezone specification (e.g. EET or Europe/Warsaw).\n" \
417+
"If pytz is not installed, value must be integer number\n" \
418+
"giving local timezone offset from UTC in hours."
419+
420+
def str2value(self, value):
421+
try:
422+
roundup.date.get_timezone(value)
423+
except KeyError:
424+
raise OptionValueError(self, value,
425+
"Timezone name or numeric hour offset required")
426+
return value
427+
410428
### Main configuration layout.
411429
# Config is described as a sequence of sections,
412430
# where each section name is followed by a sequence
@@ -463,12 +481,8 @@ class NullableFilePathOption(NullableOption, FilePathOption):
463481
"If you wish to make them xhtml, then you'll need to change this\n"
464482
"var to 'xhtml' too so all auto-generated HTML is compliant.\n"
465483
"Allowed values: html4, xhtml"),
466-
# It seems to me that all timezone offsets in the modern world
467-
# are integral hours. However, there were fractional hour offsets
468-
# in the past. Use float number for sure.
469-
(FloatNumberOption, "timezone", "0",
470-
"Numeric timezone offset used when users do not choose their own\n"
471-
"in their settings.",
484+
(TimezoneOption, "timezone", "UTC", "Default timezone offset,"
485+
" applied when user's timezone is not set.",
472486
["DEFAULT_TIMEZONE"]),
473487
(BooleanOption, "instant_registration", "no",
474488
"Register new users instantly, or require confirmation via\n"

0 commit comments

Comments
 (0)