globalize icon indicating copy to clipboard operation
globalize copied to clipboard

Unicode skeleton C not supported

Open AndreR opened this issue 6 years ago • 6 comments

I wanted to use the skeleton character C in my skeleton, but it doesn't work. I get the following error message:

E_INVALID_OPTIONS: Invalid field C of skeleton C

AndreR avatar Sep 07 '17 11:09 AndreR

Same for U, u, Y ...

gallofeliz avatar May 23 '19 10:05 gallofeliz

Correct, not all symbols are currently supported, but we're open to support it.

The C symbol is a flexible hour pattern, which is somewhat similar to j (details in UTS#35)):

It must not occur in pattern or skeleton data. Instead, it is reserved for use in skeletons passed to APIs doing flexible date pattern generation. In such a context, like 'j', it requests the preferred hour format for the locale. However, unlike 'j', it can also select formats such as hb or hB, since it is based not on the preferred attribute of the hours element in supplemental data, but instead on the first element of the allowed attribute (which is an ordered preferrence list. For example, with "Cmm", 18:00 could appear as “6:00 in the afternoon”.

For implementing C, take a look at j here and here. Or even better (since C is an Input skeleton symbol, not a pattern symbol) it should be handled at skeleton expansion phase src/date/expand-pattern.js.

rxaviers avatar May 23 '19 12:05 rxaviers

About my need, I don't know for the moment. I searched to format "arabic" dates, for example year 2019 -> 1440. But first at all, I don't know if 1440 is correct (if it is really used) and then if I need to use U, u or Y, or ... It could be nice to add the information "Partially supported" in the Globalize documentation.

Regards,

gallofeliz avatar May 23 '19 12:05 gallofeliz

@gallofeliz you may be interested to look at #320

rxaviers avatar May 23 '19 13:05 rxaviers

It could be nice to add the information "Partially supported" in the Globalize documentation

:+1: agreed. Wanna go ahead and submit a PR? Thanks

rxaviers avatar May 23 '19 13:05 rxaviers

Thanks for https://github.com/globalizejs/globalize/issues/320.

About the PR, I will see depending of my calendar.

Regards,

gallofeliz avatar May 23 '19 13:05 gallofeliz