2 #############################################################################
4 ## Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
5 ## All rights reserved.
6 ## Contact: Nokia Corporation (qt-info@nokia.com)
8 ## This file is part of the test suite of the Qt Toolkit.
10 ## $QT_BEGIN_LICENSE:LGPL$
11 ## GNU Lesser General Public License Usage
12 ## This file may be used under the terms of the GNU Lesser General Public
13 ## License version 2.1 as published by the Free Software Foundation and
14 ## appearing in the file LICENSE.LGPL included in the packaging of this
15 ## file. Please review the following information to ensure the GNU Lesser
16 ## General Public License version 2.1 requirements will be met:
17 ## http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
19 ## In addition, as a special exception, Nokia gives you certain additional
20 ## rights. These rights are described in the Nokia Qt LGPL Exception
21 ## version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
23 ## GNU General Public License Usage
24 ## Alternatively, this file may be used under the terms of the GNU General
25 ## Public License version 3.0 as published by the Free Software Foundation
26 ## and appearing in the file LICENSE.GPL included in the packaging of this
27 ## file. Please review the following information to ensure the GNU General
28 ## Public License version 3.0 requirements will be met:
29 ## http://www.gnu.org/copyleft/gpl.html.
32 ## Alternatively, this file may be used in accordance with the terms and
33 ## conditions contained in a signed written agreement between you and Nokia.
41 #############################################################################
45 def _convert_pattern(pattern):
46 # patterns from http://www.unicode.org/reports/tr35/#Date_Format_Patterns
48 r"yyy{3,}" : "yyyy", # more that three digits hence convert to four-digit year
49 r"L" : "M", # stand-alone month names. not supported.
50 r"g{1,}": "", # modified julian day. not supported.
51 r"S{1,}" : "", # fractional seconds. not supported.
52 r"A{1,}" : "" # milliseconds in day. not supported.
55 "G" : "", "GG" : "", "GGG" : "", "GGGG" : "", "GGGGG" : "", # Era. not supported.
56 "y" : "yyyy", # four-digit year without leading zeroes
57 "Q" : "", "QQ" : "", "QQQ" : "", "QQQQ" : "", # quarter. not supported.
58 "q" : "", "qq" : "", "qqq" : "", "qqqq" : "", # quarter. not supported.
59 "MMMMM" : "MMM", # narrow month name.
60 "LLLLL" : "MMM", # stand-alone narrow month name.
61 "l" : "", # special symbol for chinese leap month. not supported.
62 "w" : "", "W" : "", # week of year/month. not supported.
63 "D" : "", "DD" : "", "DDD" : "", # day of year. not supported.
64 "F" : "", # day of week in month. not supported.
65 "E" : "ddd", "EE" : "ddd", "EEE" : "ddd", "EEEEE" : "ddd", "EEEE" : "dddd", # day of week
66 "e" : "ddd", "ee" : "ddd", "eee" : "ddd", "eeeee" : "ddd", "eeee" : "dddd", # local day of week
67 "c" : "ddd", "cc" : "ddd", "ccc" : "ddd", "ccccc" : "ddd", "cccc" : "dddd", # stand-alone local day of week
69 "K" : "h", # Hour 0-11
70 "k" : "H", # Hour 1-24
71 "j" : "", # special reserved symbol.
72 "z" : "t", "zz" : "t", "zzz" : "t", "zzzz" : "t", # timezone
73 "Z" : "t", "ZZ" : "t", "ZZZ" : "t", "ZZZZ" : "t", # timezone
74 "v" : "t", "vv" : "t", "vvv" : "t", "vvvv" : "t", # timezone
75 "V" : "t", "VV" : "t", "VVV" : "t", "VVVV" : "t" # timezone
77 if qt_patterns.has_key(pattern):
78 return qt_patterns[pattern]
79 for r,v in qt_regexps.items():
80 pattern = re.sub(r, v, pattern)
83 def convert_date(input):
85 patterns = "GyYuQqMLlwWdDFgEecahHKkjmsSAzZvV"
101 converted = _convert_pattern(last)
104 result = result.rstrip(chars_to_strip)
109 converted = _convert_pattern(last)
112 result = result.rstrip(chars_to_strip)
116 converted = _convert_pattern(last)
119 result = result.rstrip(chars_to_strip)
120 return result.lstrip(chars_to_strip)