Paul J. Lucas has proposed merging lp:~paul-lucas/zorba/bug-1175752 into lp:zorba.
Commit message: Now including "[Calendar: X]" for month of unsupported calendar. Requested reviews: Paul J. Lucas (paul-lucas) Related bugs: Bug #1175752 in Zorba: ""format-date-en152" and "format-dateTime-en152" failing" https://bugs.launchpad.net/zorba/+bug/1175752 For more details, see: https://code.launchpad.net/~paul-lucas/zorba/bug-1175752/+merge/162519 Now including "[Calendar: X]" for month of unsupported calendar. -- https://code.launchpad.net/~paul-lucas/zorba/bug-1175752/+merge/162519 Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'ChangeLog' --- ChangeLog 2013-05-01 18:37:44 +0000 +++ ChangeLog 2013-05-04 18:48:26 +0000 @@ -47,6 +47,7 @@ * Fixed bug #1167704 (Implement [w] for ISO calendars for format-date/time functions) * Fixed bug #1114228 (unrecognized options in the XQuery namespace now raise an error) * Fixed bug #1124273 (xqdoc crash because of annotation literals) + * Fixed bug #1175752 ("format-date-en152" and "format-dateTime-en152" failing) * Fixed bug #1085408 (xs:date(): casting large year values) * Fixed bug #867027 (XQST0059 error messages inconsistent) * Fixed fn:nilled function === modified file 'src/runtime/durations_dates_times/format_dateTime.cpp' --- src/runtime/durations_dates_times/format_dateTime.cpp 2013-04-23 06:09:42 +0000 +++ src/runtime/durations_dates_times/format_dateTime.cpp 2013-05-04 18:48:26 +0000 @@ -313,6 +313,22 @@ // no break; } default: + int const new_mon = calendar::convert_mon_to( mon, mod.cal ); + if ( mod.cal_is_fallback || new_mon == -1 ) { + // + // Ibid: If the fallback representation uses a different calendar from + // that requested, the output string must identify the calendar + // actually used, for example by prefixing the string with [Calendar: + // X] (where X is the calendar actually used), localized as appropriate + // to the requested language. + // + ostringstream oss; + // TODO: localize "Calendar" + oss << "[Calendar: " + << (new_mon == -1 ? calendar::get_default() : mod.cal) << ']'; + *dest += oss.str(); + } else + mon = new_mon; append_number( mon + 1, mod_copy, dest ); } } @@ -552,7 +568,7 @@ ostringstream oss; // TODO: localize "Calendar" oss << "[Calendar: " - << ( new_wday == -1 ? calendar::get_default() : mod.cal ) << ']'; + << (new_wday == -1 ? calendar::get_default() : mod.cal) << ']'; *dest += oss.str(); } else wday = new_wday; @@ -563,9 +579,9 @@ static void append_week_in_month( unsigned mday, unsigned mon, unsigned year, modifier const &mod, zstring *dest ) { - int week = time::calendar::calc_week_in_month( mday, mon, year, mod.cal ); + int week = calendar::calc_week_in_month( mday, mon, year, mod.cal ); if ( week == -1 ) { - week = time::calendar::calc_week_in_month( mday, mon, year, calendar::ISO ); + week = calendar::calc_week_in_month( mday, mon, year, calendar::ISO ); ostringstream oss; // TODO: localize "Calendar" oss << "[Calendar: " << calendar::string_of[ calendar::ISO ] << ']'; @@ -576,9 +592,9 @@ static void append_week_in_year( unsigned mday, unsigned mon, unsigned year, modifier const &mod, zstring *dest ) { - int week = time::calendar::calc_week_in_year( mday, mon, year, mod.cal ); + int week = calendar::calc_week_in_year( mday, mon, year, mod.cal ); if ( week == -1 ) { - week = time::calendar::calc_week_in_year( mday, mon, year, calendar::ISO ); + week = calendar::calc_week_in_year( mday, mon, year, calendar::ISO ); ostringstream oss; // TODO: localize "Calendar" oss << "[Calendar: " << calendar::string_of[ calendar::ISO ] << ']'; === modified file 'src/util/time_util.cpp' --- src/util/time_util.cpp 2013-05-03 23:19:41 +0000 +++ src/util/time_util.cpp 2013-05-04 18:48:26 +0000 @@ -177,6 +177,16 @@ } } +int convert_mon_to( unsigned mon, type to ) { + switch ( to ) { + case AD: + case ISO: + return (int)mon; + default: + return -1; + } +} + int convert_wday_from( unsigned wday, type from ) { switch ( from ) { case AD: === modified file 'src/util/time_util.h' --- src/util/time_util.h 2013-04-23 06:09:42 +0000 +++ src/util/time_util.h 2013-05-04 18:48:26 +0000 @@ -120,6 +120,16 @@ int calc_week_in_year( unsigned mday, unsigned mon, unsigned year, type cal ); /** + * Converts a Unix month number to a specific calendar. + * + * @param mon The month to convert: [0-11]. + * @param to The calendar designator to convert \a mon to. + * @return Returns \a mon converted to \a to or -1 if is unknown hot to + * perform the conversion. + */ + int convert_mon_to( unsigned mon, type to ); + + /** * Converts a weekday number from a given calendar to the Unix interpretation * [0-6] where 0 = Sunday. * === modified file 'test/fots/CMakeLists.txt' --- test/fots/CMakeLists.txt 2013-05-03 23:46:41 +0000 +++ test/fots/CMakeLists.txt 2013-05-04 18:48:26 +0000 @@ -118,8 +118,6 @@ #"disputed" tests. These test are run but marked as 'pass' by FOTS driver. #All these entries should have a *valid* opened bug number from W3C bugzilla. EXPECTED_FOTS_FAILURE (DISPUTED fn-format-integer format-integer-044 21448) -EXPECTED_FOTS_FAILURE (DISPUTED fn-format-date format-date-en152 21558) -EXPECTED_FOTS_FAILURE (DISPUTED fn-format-dateTime format-dateTime-en152 21558) EXPECTED_FOTS_FAILURE (DISPUTED prod-OrderByClause orderBy20 21619) EXPECTED_FOTS_FAILURE (DISPUTED prod-OrderByClause orderBy21 21619) EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-001 21568)
-- Mailing list: https://launchpad.net/~zorba-coders Post to : zorba-coders@lists.launchpad.net Unsubscribe : https://launchpad.net/~zorba-coders More help : https://help.launchpad.net/ListHelp