wyldcard icon indicating copy to clipboard operation
wyldcard copied to clipboard

tests using long dates fail (problems with locale settings)

Open rozek opened this issue 3 years ago • 2 comments

First of all: thank you very much for this marvelous project!

I just started playing around with it:

  • gradlew run worked out-of-the-box - very well done!
  • but gradlew generateBundle failed because of two failing tests
ValueTest > testDateStyledCompare() FAILED
    org.opentest4j.AssertionFailedError at ValueTest.java:871

ValueTest > testIsADate() FAILED
    org.opentest4j.AssertionFailedError at ValueTest.java:727

both are related to "long date" formats, e.g.

assertTrue(new Value("Monday, January 1, 1985").isA(new Value("date")).booleanValue());     // Long date

and

assertEquals(1, new Value("Monday, January 1, 2000").compareTo(new Value("Monday, December 31, 1999"), SortStyle.DATE_TIME));

Long dates don't seem to be recognized.

~~I did not find the time to further investigate the problem, though, and, thus, may also be wrong.~~

My system is a Mac with german locale...

Edit: indeed, tests seem to fail because of the locale settings: (in HyperTalk) put "Sonntag, April 24, 2022" is a date displays true but put "Sunday, April 24, 2022" is a date displays false The question will now be: do you want dates to always be handled in english locale or to respect the system's locale setting?

Edit 2: as a hint: numbers are always parsed using the english locale (e.g., "1.23" is a number whereas "1,23" is not, although the german locale uses "," instead of "."). As a consequence, you may prefer to always handle dates in english locale...

With greetings from Germany,

Andreas Rozek

rozek avatar Apr 24 '22 03:04 rozek

Hi @rozek ,

Guten Abend, Deutschland. Grüße aus Chicago.

First, in case others run into this problem, you can execute ./gradlew generateBundle -x test to build the distributable with executing the unit tests.

You're quite right about the locale issue: I made no attempt to handle internationalization in the project. I think the right answer is that HyperTalk should respect the system's locale when parsing or producing both dates and numbers. Of course, this means that scripts are effectively non-portable between locales. Hmm...

Do you happen to know how HyperCard addressed this?

defano avatar Apr 24 '22 18:04 defano

Good morning!

Trying both

  • put "Sonntag, April 24, 2022" is a date and
  • put "Sunday, April 24, 2022" is a date

in the message box of HyperCard 2.4.1 running within an Infinite Mac (macOS 8) gave true in both cases (I even changed "Date Formats" and "Time Formats" to "German" using the "Date & Time" control panel).

Although I haven't made systematic tests it seems as if HyperCard could handle dates and times in the english format regardless of the current locale...

rozek avatar Apr 25 '22 04:04 rozek