Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

locale-dependent test failure for day-of-week #42

Open
dilbernd opened this issue Sep 7, 2019 · 3 comments
Open

locale-dependent test failure for day-of-week #42

dilbernd opened this issue Sep 7, 2019 · 3 comments

Comments

@dilbernd
Copy link

@dilbernd dilbernd commented Sep 7, 2019

Building 707f16daf19e04cf182cc532a2cce8db170ea178 using Leiningen, I get a test failure:

FAIL in (constructors) (java_time_test.clj:61)
enums
expected: (= (j/day-of-week 4) (j/day-of-week :thursday) (j/day-of-week (j/local-date clock)) (j/day-of-week "ee" "05"))
  actual: (not (= #object[java.time.DayOfWeek 0x9d818b5 "THURSDAY"] #object[java.time.DayOfWeek 0x9d818b5 "THURSDAY"] #object[java.time.DayOfWeek 0x9d818b5 "THURSDAY"] #object[java.time.DayOfWeek 0x4f8e6101 "FRIDAY"]))

This is a locale issue. In a REPL with my system locale (English in Austria):

(ns jt-test (:require [java-time :as jt] [java-time.format :as jtf]))
=> nil
(jt/day-of-week (jtf/parse "ee" "05"))
=> #object[java.time.DayOfWeek 0x6ab351fe "FRIDAY"]

In a REPL with -Duser.country=US set on the JVM:

(ns jt-test (:require [java-time :as jt] [java-time.format :as jtf]))
=> nil
(jt/day-of-week (jtf/parse "ee" "05"))
=> #object[java.time.DayOfWeek 0x67860a8c "THURSDAY"]

This is consistent with the expected first DoW being Sunday in the US, but Monday in (at least continental) Europe.

@dilbernd dilbernd changed the title locale-dependent test failures for day-of-week locale-dependent test failure for day-of-week Sep 7, 2019
@dm3
Copy link
Owner

@dm3 dm3 commented Nov 13, 2019

Thanks for the report! What would you think would be the right solution for the issue?

@dilbernd
Copy link
Author

@dilbernd dilbernd commented Nov 17, 2019

No idea, sorry.

(Thought about it a bit when I discovered it; really drove home the value of explicit parameter (or closure/partials) dependencies, this is errno all over.)

@dm3
Copy link
Owner

@dm3 dm3 commented Jan 2, 2020

The solution for this issue - make the tests locale-independent. Easiest - remove the offender identified in this issue from the tests. Harder - set the default TZ to the known value during test execution and revert to the previous value afterwards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.