Re: Libreoffice Latvian format

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Julien,

On Monday, 2021-05-03 22:02:57 +0200, Julien Nabet wrote:

> i18npool/source/localedata/data/lv_LV.xml contains:
> 
>     110     <FormatElement msgid="DateFormatskey9" default="true"
> type="long" usage="DATE" formatindex="19">
>     111       <FormatCode>YYYY. "gada" DD. MMMM, NNNN</FormatCode>
>     112     </FormatElement>

That's odd, but well..


> So I thought about this patch:
> --- a/unotools/source/i18n/localedatawrapper.cxx
> +++ b/unotools/source/i18n/localedatawrapper.cxx
> @@ -780,6 +780,12 @@ DateOrder LocaleDataWrapper::scanDateOrderImpl( const
> OUString& rCode ) const
>          return DateOrder::YMD;
>      else
>      {
> +        // lv_LV can use:
> +        // - YYYY. "gada" DD. MMMM, NNNN
> +        // - NNNN, YYYY. "gada" DD. MMMM
> +        if ( nYear <= nDay && nDay << nMonth && rCode.indexOf('g') != -1)
> +            return DateOrder::YDM;

If we would really introduce DateOrder::YDM the extra check for
rCode.indexOf('g') as an lv-LV speciality wouldn't be necessary.
(btw, it should be "nDay <= nMonth" instead of "nDay << nMonth", and the
condition be made another else if like the others).

> but DateOrder::YDM doesn't exist:
> 
> 48  enum class DateOrder {
> 49      Invalid = -1,
> 50      MDY = 0,
> 51      DMY,
> 52      YMD,
> 53  };
> 
> Any thoughts here? Should I add this other DateOrder const?

Ugh.. there are quite some places that assume only the three values
exist. Anything using those would have to be inspected what happens with
the new value, and possibly adapting. ( git grep DateOrder:: )

I haven't encountered YDM in short or medium date formats, so maybe that
should be reserved for long date formats. Which then would be an
additional LongDateOrder enum used only with
LocaleDataWrapper::getLongDateOrder(), narrowing down the having to
be adjusted cases quite by some and avoiding unnecessary code and
complications.

  Eike

-- 
GPG key 0x6A6CD5B765632D3A - 2265 D7F3 A7B0 95CC 3918  630B 6A6C D5B7 6563 2D3A

Attachment: signature.asc
Description: PGP signature

_______________________________________________
LibreOffice mailing list
LibreOffice@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/libreoffice

[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux