gustafn
committed
on 16 Feb 24
Fixed unreviewed commit, which might lead to hard-to-spot errors

The last change assumed that "nls_language" can be hard-wired to
contain m… Show more
Fixed unreviewed commit, which might lead to hard-to-spot errors

The last change assumed that "nls_language" can be hard-wired to

contain most 5 characters. While this not backed by the OpenACS data

model, the standard (RFC 5646) explicitly states that there is no

upper limit on the size of language tags. The tree letter language

codes have been standard since 2001 (RFC 4646).

The change accepts now all defined locales. When the specified locale

is not enabled, it provides a log notice, when the locale is not

defined at all, it provides a warning and falls back to "en_US".

Show less

/test/acs-lang-localization-procs.tcl (+8 -0)
244 244         set time [lc_time_local_to_utc "0621-01-01 00:00:00" $tz]
245 245         aa_equals "lc_time_local_to_utc from Europe/Vienna (0621-01-01 00:00:00)" $time "0620-12-31 22:54:39"
246 246
247 247         set time [lc_time_local_to_utc "1581-01-01 00:00:00" $tz]
248 248         aa_equals "lc_time_local_to_utc from Europe/Vienna (1581-01-01 00:00:00)" $time "1580-12-31 22:54:39"
249 249
250 250         set time [lc_time_local_to_utc "1583-01-01 00:00:00" $tz]
251 251         aa_equals "lc_time_local_to_utc from Europe/Vienna (1583-01-01 00:00:00)" $time "1582-12-31 22:54:39"
252 252
253 253         set time [lc_time_local_to_utc "2000-00-00 00:00:00" $tz]
254 254         aa_equals "lc_time_local_to_utc from Europe/Vienna (2000-00-00 00:00:00)" $time "1999-11-29 23:00:00"
255 255
256 256         aa_equals "lc_time_local_to_utc from Europe/Vienna ('Broken!', invalid date)" \
257 257             [lc_time_local_to_utc "Broken!" $tz] ""
258 258
259 259         set time [lc_time_local_to_utc "1900-01-01 00:00:00" $tz]
260 260         aa_equals "lc_time_local_to_utc from Europe/Vienna (1900-01-01 00:00:00)" $time "1899-12-31 23:00:00"
261 261
262 262         foreach from $timezones {
263 263             set from [lindex $from 0]
  264             try {
  265                 clock scan 99999 -timezone $from
  266             } on error {errorMsg} {
  267                 if {[string match "time zone *not found" $errorMsg]} {
  268                     aa_log "warning: Tcl does not know about time zome $from"
  269                     continue
  270                 }
  271             }
264 272             aa_false "Converting valid date '2021-02-18 15:04:59' from valid timezone '$from' to 'UTC' does not return empty or 0" \
265 273                 [expr {[lc_time_local_to_utc "2021-02-18 15:04:59" $from] eq ""}]
266 274         }
267 275
268 276     }
269 277
270 278 aa_register_case \
271 279     -cats {api smoke production_safe} \
272 280     -procs {
273 281         lc_get
274 282         lc_numeric
275 283         lc_content_size_pretty
276 284     } lang_test__lc_content_size_pretty {
277 285
278 286         Test lc_content_size_pretty proc
279 287
280 288         @author Héctor Romojaro <hector.romojaro@gmail.com>
281 289         @creation-date 2019-06-25
282 290
283 291 } {