author | zautrix <zautrix> | 2004-10-22 22:10:16 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-22 22:10:16 (UTC) |
commit | b8da6435b8e5941eb1824873e68d8a6a728fae5e (patch) (unidiff) | |
tree | bc5ed11961e89bcd606f6fbca32185dbf8afab7a /microkde | |
parent | a5274f27dc71e1a0ffae73f32f84f4dd013b4b76 (diff) | |
download | kdepimpi-b8da6435b8e5941eb1824873e68d8a6a728fae5e.zip kdepimpi-b8da6435b8e5941eb1824873e68d8a6a728fae5e.tar.gz kdepimpi-b8da6435b8e5941eb1824873e68d8a6a728fae5e.tar.bz2 |
fixed an ugly timezone bug
-rw-r--r-- | microkde/kdecore/klocale.cpp | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/microkde/kdecore/klocale.cpp b/microkde/kdecore/klocale.cpp index 21e6937..d3b04dc 100644 --- a/microkde/kdecore/klocale.cpp +++ b/microkde/kdecore/klocale.cpp | |||
@@ -38,217 +38,217 @@ void dumpMissing() | |||
38 | QTextStream ts( &file ); | 38 | QTextStream ts( &file ); |
39 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 39 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
40 | 40 | ||
41 | int i; | 41 | int i; |
42 | for ( i = 0; i< missingTrans.count(); ++i ) { | 42 | for ( i = 0; i< missingTrans.count(); ++i ) { |
43 | 43 | ||
44 | QString text = missingTrans[i].replace( QRegExp("\n"),"\\n" ); | 44 | QString text = missingTrans[i].replace( QRegExp("\n"),"\\n" ); |
45 | ts << "{ \""<<text<< "\",\""<< text <<"\" },\n"; | 45 | ts << "{ \""<<text<< "\",\""<< text <<"\" },\n"; |
46 | 46 | ||
47 | } | 47 | } |
48 | file.close(); | 48 | file.close(); |
49 | } | 49 | } |
50 | 50 | ||
51 | QString i18n(const char *text) | 51 | QString i18n(const char *text) |
52 | { | 52 | { |
53 | if ( ! mLocaleDict ) { | 53 | if ( ! mLocaleDict ) { |
54 | addMissing( text ); | 54 | addMissing( text ); |
55 | return QString( text ); | 55 | return QString( text ); |
56 | } | 56 | } |
57 | else { | 57 | else { |
58 | QString* ret = mLocaleDict->find(QString(text)) ; | 58 | QString* ret = mLocaleDict->find(QString(text)) ; |
59 | if ( ret == 0 ) { | 59 | if ( ret == 0 ) { |
60 | addMissing( text ); | 60 | addMissing( text ); |
61 | return QString( text ); | 61 | return QString( text ); |
62 | } | 62 | } |
63 | else { | 63 | else { |
64 | if ( (*ret).isEmpty() ) { | 64 | if ( (*ret).isEmpty() ) { |
65 | addMissing( text ); | 65 | addMissing( text ); |
66 | return QString( text ); | 66 | return QString( text ); |
67 | } | 67 | } |
68 | else | 68 | else |
69 | return (*ret); | 69 | return (*ret); |
70 | } | 70 | } |
71 | } | 71 | } |
72 | 72 | ||
73 | } | 73 | } |
74 | 74 | ||
75 | QString i18n(const char *,const char *text) | 75 | QString i18n(const char *,const char *text) |
76 | { | 76 | { |
77 | return i18n( text ); | 77 | return i18n( text ); |
78 | } | 78 | } |
79 | 79 | ||
80 | QString i18n(const char *text1, const char *textn, int num) | 80 | QString i18n(const char *text1, const char *textn, int num) |
81 | { | 81 | { |
82 | if ( num == 1 ) return i18n( text1 ); | 82 | if ( num == 1 ) return i18n( text1 ); |
83 | else { | 83 | else { |
84 | QString text = i18n( textn ); | 84 | QString text = i18n( textn ); |
85 | int pos = text.find( "%n" ); | 85 | int pos = text.find( "%n" ); |
86 | if ( pos >= 0 ) text.replace( pos, 2, QString::number( num ) ); | 86 | if ( pos >= 0 ) text.replace( pos, 2, QString::number( num ) ); |
87 | return text; | 87 | return text; |
88 | } | 88 | } |
89 | } | 89 | } |
90 | 90 | ||
91 | inline void put_it_in( QChar *buffer, uint& index, const QString &s ) | 91 | inline void put_it_in( QChar *buffer, uint& index, const QString &s ) |
92 | { | 92 | { |
93 | for ( uint l = 0; l < s.length(); l++ ) | 93 | for ( uint l = 0; l < s.length(); l++ ) |
94 | buffer[index++] = s.at( l ); | 94 | buffer[index++] = s.at( l ); |
95 | } | 95 | } |
96 | 96 | ||
97 | inline void put_it_in( QChar *buffer, uint& index, int number ) | 97 | inline void put_it_in( QChar *buffer, uint& index, int number ) |
98 | { | 98 | { |
99 | buffer[index++] = number / 10 + '0'; | 99 | buffer[index++] = number / 10 + '0'; |
100 | buffer[index++] = number % 10 + '0'; | 100 | buffer[index++] = number % 10 + '0'; |
101 | } | 101 | } |
102 | 102 | ||
103 | static int readInt(const QString &str, uint &pos) | 103 | static int readInt(const QString &str, uint &pos) |
104 | { | 104 | { |
105 | if (!str.at(pos).isDigit()) return -1; | 105 | if (!str.at(pos).isDigit()) return -1; |
106 | int result = 0; | 106 | int result = 0; |
107 | for (; str.length() > pos && str.at(pos).isDigit(); pos++) | 107 | for (; str.length() > pos && str.at(pos).isDigit(); pos++) |
108 | { | 108 | { |
109 | result *= 10; | 109 | result *= 10; |
110 | result += str.at(pos).digitValue(); | 110 | result += str.at(pos).digitValue(); |
111 | } | 111 | } |
112 | 112 | ||
113 | return result; | 113 | return result; |
114 | } | 114 | } |
115 | 115 | ||
116 | KLocale::KLocale() : mCalendarSystem( 0 ) | 116 | KLocale::KLocale() : mCalendarSystem( 0 ) |
117 | { | 117 | { |
118 | 118 | ||
119 | m_decimalSymbol = "."; | 119 | m_decimalSymbol = "."; |
120 | m_positiveSign = ""; | 120 | m_positiveSign = ""; |
121 | m_negativeSign = "-"; | 121 | m_negativeSign = "-"; |
122 | m_thousandsSeparator = ","; | 122 | m_thousandsSeparator = ","; |
123 | 123 | ||
124 | 124 | ||
125 | 125 | ||
126 | 126 | ||
127 | mWeekStartsMonday = true; | 127 | mWeekStartsMonday = true; |
128 | mHourF24Format = true; | 128 | mHourF24Format = true; |
129 | mIntDateFormat = Default; | 129 | mIntDateFormat = Default; |
130 | mIntTimeFormat = Default; | 130 | mIntTimeFormat = Default; |
131 | mLanguage = 0; | 131 | mLanguage = 0; |
132 | mDateFormat = "%a %Y %b %d"; | 132 | mDateFormat = "%a %Y %b %d"; |
133 | mDateFormatShort = "%Y-%m-%d"; | 133 | mDateFormatShort = "%Y-%m-%d"; |
134 | mTimeZoneList << i18n ("-11:00 US/Samoa") | 134 | mTimeZoneList << ("-11:00 US/Samoa") |
135 | << i18n ("-10:00 US/Hawaii") | 135 | << ("-10:00 US/Hawaii") |
136 | << i18n ("-09:00 US/Alaska") | 136 | << ("-09:00 US/Alaska") |
137 | << i18n ("-08:00 US/Pacific") | 137 | << ("-08:00 US/Pacific") |
138 | << i18n ("-07:00 US/Mountain") | 138 | << ("-07:00 US/Mountain") |
139 | << i18n ("-06:00 US/Central") | 139 | << ("-06:00 US/Central") |
140 | << i18n ("-05:00 US/Eastern") | 140 | << ("-05:00 US/Eastern") |
141 | << i18n ("-04:00 Brazil/West") | 141 | << ("-04:00 Brazil/West") |
142 | << i18n ("-03:00 Brazil/East") | 142 | << ("-03:00 Brazil/East") |
143 | << i18n ("-02:00 Brazil/DeNoronha") | 143 | << ("-02:00 Brazil/DeNoronha") |
144 | << i18n ("-01:00 Atlantic/Azores") | 144 | << ("-01:00 Atlantic/Azores") |
145 | << i18n (" 00:00 Europe/London(UTC)") | 145 | << (" 00:00 Europe/London(UTC)") |
146 | << i18n ("+01:00 Europe/Oslo(CET)") | 146 | << ("+01:00 Europe/Oslo(CET)") |
147 | << i18n ("+02:00 Europe/Helsinki") | 147 | << ("+02:00 Europe/Helsinki") |
148 | << i18n ("+03:00 Europe/Moscow") | 148 | << ("+03:00 Europe/Moscow") |
149 | << i18n ("+04:00 Indian/Mauritius") | 149 | << ("+04:00 Indian/Mauritius") |
150 | << i18n ("+05:00 Indian/Maldives") | 150 | << ("+05:00 Indian/Maldives") |
151 | << i18n ("+06:00 Indian/Chagos") | 151 | << ("+06:00 Indian/Chagos") |
152 | << i18n ("+07:00 Asia/Bangkok") | 152 | << ("+07:00 Asia/Bangkok") |
153 | << i18n ("+08:00 Asia/Hongkong") | 153 | << ("+08:00 Asia/Hongkong") |
154 | << i18n ("+09:00 Asia/Tokyo") | 154 | << ("+09:00 Asia/Tokyo") |
155 | << i18n ("+10:00 Asia/Vladivostok") | 155 | << ("+10:00 Asia/Vladivostok") |
156 | << i18n ("+11:00 Asia/Magadan") | 156 | << ("+11:00 Asia/Magadan") |
157 | << i18n ("+12:00 Asia/Kamchatka") | 157 | << ("+12:00 Asia/Kamchatka") |
158 | // << i18n (" xx:xx User defined offset") | 158 | // << (" xx:xx User defined offset") |
159 | << i18n (" Local Time"); | 159 | << i18n (" Local Time"); |
160 | mSouthDaylight = false; | 160 | mSouthDaylight = false; |
161 | mTimeZoneOffset = 0; | 161 | mTimeZoneOffset = 0; |
162 | daylightEnabled = false; | 162 | daylightEnabled = false; |
163 | } | 163 | } |
164 | 164 | ||
165 | void KLocale::setDateFormat( QString s ) | 165 | void KLocale::setDateFormat( QString s ) |
166 | { | 166 | { |
167 | mDateFormat = s; | 167 | mDateFormat = s; |
168 | } | 168 | } |
169 | 169 | ||
170 | void KLocale::setDateFormatShort( QString s ) | 170 | void KLocale::setDateFormatShort( QString s ) |
171 | { | 171 | { |
172 | mDateFormatShort = s; | 172 | mDateFormatShort = s; |
173 | } | 173 | } |
174 | 174 | ||
175 | void KLocale::setHore24Format ( bool b ) | 175 | void KLocale::setHore24Format ( bool b ) |
176 | { | 176 | { |
177 | mHourF24Format = b; | 177 | mHourF24Format = b; |
178 | } | 178 | } |
179 | void KLocale::setWeekStartMonday( bool b ) | 179 | void KLocale::setWeekStartMonday( bool b ) |
180 | { | 180 | { |
181 | mWeekStartsMonday = b; | 181 | mWeekStartsMonday = b; |
182 | } | 182 | } |
183 | 183 | ||
184 | KLocale::IntDateFormat KLocale::getIntDateFormat( ) | 184 | KLocale::IntDateFormat KLocale::getIntDateFormat( ) |
185 | { | 185 | { |
186 | return mIntDateFormat; | 186 | return mIntDateFormat; |
187 | 187 | ||
188 | } | 188 | } |
189 | void KLocale::setIntDateFormat( KLocale::IntDateFormat i ) | 189 | void KLocale::setIntDateFormat( KLocale::IntDateFormat i ) |
190 | { | 190 | { |
191 | mIntDateFormat = i; | 191 | mIntDateFormat = i; |
192 | } | 192 | } |
193 | KLocale::IntDateFormat KLocale::getIntTimeFormat( ) | 193 | KLocale::IntDateFormat KLocale::getIntTimeFormat( ) |
194 | { | 194 | { |
195 | return mIntTimeFormat; | 195 | return mIntTimeFormat; |
196 | 196 | ||
197 | } | 197 | } |
198 | void KLocale::setIntTimeFormat( KLocale::IntDateFormat i ) | 198 | void KLocale::setIntTimeFormat( KLocale::IntDateFormat i ) |
199 | { | 199 | { |
200 | mIntTimeFormat = i; | 200 | mIntTimeFormat = i; |
201 | } | 201 | } |
202 | 202 | ||
203 | void KLocale::setLanguage( int i ) | 203 | void KLocale::setLanguage( int i ) |
204 | { | 204 | { |
205 | mLanguage = i; | 205 | mLanguage = i; |
206 | } | 206 | } |
207 | int KLocale::language( ) | 207 | int KLocale::language( ) |
208 | { | 208 | { |
209 | return mLanguage; | 209 | return mLanguage; |
210 | } | 210 | } |
211 | QString KLocale::translate( const char *index ) const | 211 | QString KLocale::translate( const char *index ) const |
212 | { | 212 | { |
213 | return i18n( index ); | 213 | return i18n( index ); |
214 | } | 214 | } |
215 | 215 | ||
216 | QString KLocale::translate( const char *, const char *fallback) const | 216 | QString KLocale::translate( const char *, const char *fallback) const |
217 | { | 217 | { |
218 | return i18n( fallback ); | 218 | return i18n( fallback ); |
219 | } | 219 | } |
220 | 220 | ||
221 | QString KLocale::formatTime(const QTime &pTime, bool includeSecs, IntDateFormat intIntDateFormat) const | 221 | QString KLocale::formatTime(const QTime &pTime, bool includeSecs, IntDateFormat intIntDateFormat) const |
222 | { | 222 | { |
223 | const QString rst = timeFormat(intIntDateFormat); | 223 | const QString rst = timeFormat(intIntDateFormat); |
224 | 224 | ||
225 | // only "pm/am" here can grow, the rest shrinks, but | 225 | // only "pm/am" here can grow, the rest shrinks, but |
226 | // I'm rather safe than sorry | 226 | // I'm rather safe than sorry |
227 | QChar *buffer = new QChar[rst.length() * 3 / 2 + 30]; | 227 | QChar *buffer = new QChar[rst.length() * 3 / 2 + 30]; |
228 | 228 | ||
229 | uint index = 0; | 229 | uint index = 0; |
230 | bool escape = false; | 230 | bool escape = false; |
231 | int number = 0; | 231 | int number = 0; |
232 | 232 | ||
233 | for ( uint format_index = 0; format_index < rst.length(); format_index++ ) | 233 | for ( uint format_index = 0; format_index < rst.length(); format_index++ ) |
234 | { | 234 | { |
235 | if ( !escape ) | 235 | if ( !escape ) |
236 | { | 236 | { |
237 | if ( rst.at( format_index ).unicode() == '%' ) | 237 | if ( rst.at( format_index ).unicode() == '%' ) |
238 | escape = true; | 238 | escape = true; |
239 | else | 239 | else |
240 | buffer[index++] = rst.at( format_index ); | 240 | buffer[index++] = rst.at( format_index ); |
241 | } | 241 | } |
242 | else | 242 | else |
243 | { | 243 | { |
244 | switch ( rst.at( format_index ).unicode() ) | 244 | switch ( rst.at( format_index ).unicode() ) |
245 | { | 245 | { |
246 | case '%': | 246 | case '%': |
247 | buffer[index++] = '%'; | 247 | buffer[index++] = '%'; |
248 | break; | 248 | break; |
249 | case 'H': | 249 | case 'H': |
250 | put_it_in( buffer, index, pTime.hour() ); | 250 | put_it_in( buffer, index, pTime.hour() ); |
251 | break; | 251 | break; |
252 | case 'I': | 252 | case 'I': |
253 | put_it_in( buffer, index, ( pTime.hour() + 11) % 12 + 1 ); | 253 | put_it_in( buffer, index, ( pTime.hour() + 11) % 12 + 1 ); |
254 | break; | 254 | break; |