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

TimeNode test fails in GMT #3

Open
aranwe opened this issue Sep 29, 2021 · 1 comment
Open

TimeNode test fails in GMT #3

aranwe opened this issue Sep 29, 2021 · 1 comment

Comments

@aranwe
Copy link
Contributor

aranwe commented Sep 29, 2021

Test JsepTest.timeTest() fails on line 204 for User with GMT timezone:

JsepTest.cls

...
        node = (Jsep.TimeNode )new Jsep(s4).parse();
        System.assertEquals(true, node.value!=v); // line 204
        System.assertEquals(node.getType(), Jsep.JSEP_TIME);
...

Repro

Given you execute anonymously:

String s = '01:08:54.474';
String s4= '1:8:54.474Z';
Time v = (Time)JSON.deserialize('"' + s + '"', Time.class);
Jsep.TimeNode node = (Jsep.TimeNode )new Jsep(s4).parse();

System.debug(node.value!=v);
System.debug(node.value);
System.debug(v);

Then for User with timezone "Africa/Brazzaville" prints:

05:54:42.68 (80498067)|USER_DEBUG|[6]|DEBUG|true
05:54:42.68 (80559117)|USER_DEBUG|[7]|DEBUG|01:08:54.474Z
05:54:42.68 (80574435)|USER_DEBUG|[8]|DEBUG|09:08:54.474Z

For User with timezone "GMT" (or any other GMT+00:00) prints:

12:58:44.88 (100847623)|USER_DEBUG|[6]|DEBUG|false
12:58:44.88 (100898952)|USER_DEBUG|[7]|DEBUG|01:08:54.474Z
12:58:44.88 (100916055)|USER_DEBUG|[8]|DEBUG|01:08:54.474Z
@aranwe
Copy link
Contributor Author

aranwe commented Sep 29, 2021

I think that the test is bad, not the behaviour as s and subsequently v is in local timezone however s4 is always in GMT -> the test assumes that the user is not in GMT.

However I've tried to play with the offset and I am not sure I am getting the behaviour:

String s = '02:08:54.474';
String s4= '2:8:54.474Z';
Time v = (Time)JSON.deserialize('"' + s + '"', Time.class);

Jsep.TimeNode node = (Jsep.TimeNode )new Jsep(s4).parse();

DateTime now = DateTime.now();
Integer offset = (DateTime.newInstance(now.date(), now.time()).getTime()
    - DateTime.newInstance(now.dateGmt(), now.timeGmt()).getTime()).intValue();

System.debug(offset);
System.debug(node.value==v.addMilliseconds(offset));
System.debug(node.value);
System.debug(v);
System.debug(v.addMilliseconds(offset));

when in (GMT+10:30) Lord Howe Standard Time (Australia/Lord_Howe) TZ prints:

23:47:47.137 (157712680)|USER_DEBUG|[11]|DEBUG|37800000
23:47:47.137 (157845796)|USER_DEBUG|[12]|DEBUG|false
23:47:47.137 (157881363)|USER_DEBUG|[13]|DEBUG|02:08:54.474Z
23:47:47.137 (157909553)|USER_DEBUG|[14]|DEBUG|16:08:54.474Z
23:47:47.137 (157968698)|USER_DEBUG|[15]|DEBUG|02:38:54.474Z

-> it's half an hour off however 37800000 is indeed 10:30hrs.
This leaves me to think there is something else at play here.

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

No branches or pull requests

1 participant