sfsam / Itsycal

Itsycal is a tiny calendar for your Mac's menu bar. http://www.mowglii.com/itsycal
MIT License
3.3k stars 235 forks source link

Some Format Character dosen't work without an end char. #137

Closed noisnemid closed 5 years ago

noisnemid commented 5 years ago

e.g, if the format string is written as : G y/MMM/d(E/'W'w/'Q'Q) z#hh:mm:ss B the tailed 'B' will not work. but if it's written: G y/MMM/d(E/'W'w/'Q'Q) z#hh:mm:ss B/ or G y/MMM/d(E/'W'w/'Q'Q) z#hh:mm:ss B. it will be good.

sfsam commented 5 years ago

Here is what I get when I paste in the first pattern with the trailing B. It looks ok?

Screen Shot 2019-06-27 at 7 54 59 AM
noisnemid commented 5 years ago

if the formating string ends with 'B.', it'll be ok in my mac; if it ends with 'B' without '.', there will not be 'in the morning' displayed.

noisnemid commented 5 years ago

it works this time. i don't know what happened last time, but the 'in the morning' string really didn't show then. i'll keep testing it.

noisnemid commented 5 years ago

the problem got more and more interesting this time lol look!

showed_24_checked 1_no_B_showed showed_24_unchecked
sfsam commented 5 years ago

On my end, when I enable the 24-Hour Time, the B does nothing. If I disable 24-Hour Time, it says 'in the morning'. It doesn't require a trailing character after the B for it to work.

I think according to the Unicode standard, B isn't supported for 24-Hour Time, so this behavior is correct. I don't have control over how these characters are interpreted. I pass them to an Apple API that creates the time string from the format pattern. I think Apple is adhering to the standard.

From https://unicode.org/reports/tr35/tr35-dates.html: Patterns and skeletons for 24-hour-cycle time formats (using H or k) currently should not include fields with day period characters (a, b, or B); these pattern characters should be ignored if they appear in skeletons.

noisnemid commented 5 years ago

So Itsycal only transfers the string to an API and receive the interpreted result, this issue should not be tagged to 'BUG'.

Thank you very much for creating so practical and useful software, it helps me much!


PS.

At the beginning I thought this was only a tiny insignificant probelm of processing some ambiguous format string. But after reading the UNICODE LDML doc's relating sectors, and then I did some further test of the strings, I think this is a little complex but very interesting now!

Test case combinations:

Although it's meaning less to do the test if the 24-hour mode is activated according to the UNICODE LDML doc, the test cases could be recorded for refering if needed...

Uh…

Am I making simple things complex...

...

In 24-hour enabled mode, it's a little hard to predict the result by cerebrum, which is like to predict a regex's matching...less or more , they are like some undefined behaviors.

According to the doc, the result depends on the order of the patterns, too...


sfsam commented 5 years ago

Ok, I will remove the bug label and close this issue. Yes, Itsycal just passes the string to the framework to interpret the pattern. That way it is done how the system would do it and I can't mess it up. :) I think it is working the way it is supposed to work, but that is a complex topic and isn't always intuitive.