Implement isDaylightSavingTime#1083
Conversation
References fable-compiler#1082. Because JS doesn't have a native function for this, we need to check if the `Date`s UTC offset is equal to either the offset in January or in June. If a users time zone doesn't have DST, this function should always return `false`.
|
Thanks a lot for this! @forki's test should be enough to check |
|
I actually wanted to test it with some predefined values, but maybe it's just me being paranoid. 😄 In this case, there's probably no reason to make it a separate function. |
|
Don't worry. If it's releasedocs then I will write UI tests for our app
starten and test it indirectly ;-)
Am 18.07.2017 12:54 schrieb "Ilja Nosik" <notifications@github.com>:
I actually wanted to test it with some predefined values, but maybe it's
just me being paranoid. 😄
In this case, there's probably no reason to make it a separate function.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1083 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AADgNMaMPZAIdWwXhwGcDKcswDohPSTiks5sPI76gaJpZM4ObIzV>
.
|
|
@inosik thanks for implementing it. |
|
Sweet! Now I need to win some speakers for my workstation 😄 |
|
sorry guys you are missing out. |
|
Unfortunately, the fix breaks Travis CI. AppVeyor seems to be completely broken right now. |
|
Luckily my advanced hacker skills prevail over Youtube algorithm... by typing the video title in the Search Bar ;) |
|
I hate Travis, it's been failing continuously for a while now for not apparent reason 😬 |
|
AppVeyor doesn't seem to run at all at the moment, but Travis fails because of the test from #1082. |
// index.js
function isDaylightSavingTime(x) {
var jan = new Date(x.getTimezoneOffset(), 0, 1);
var jul = new Date(x.getTimezoneOffset(), 6, 1);
return isDST(jan.getTimezoneOffset(), jul.getTimezoneOffset(), x.getTimezoneOffset());
}
function isDST(janOffset, julOffset, tOffset) {
return Math.min(janOffset, julOffset) === tOffset;
}
var d1 = new Date(2017, 6, 18, 2, 0, 0);
var d2 = new Date(2017, 11, 18, 2, 0, 0);
console.log(d1.toString() + " is DST: " + isDaylightSavingTime(d1).toString());
console.log(d2.toString() + " is DST: " + isDaylightSavingTime(d2).toString());Works for me. Must be the time zone of the Travis instance. |
|
Let's see what Appveyor says and, if necessary, disable that test in the CI servers. |
|
As I wrote in #1082, this test will fail for everybody who runs it in a country without DST. That's why I wanted to test the Looks like we can control the time zone in Travis CI with the |
|
can ask for the current zone? we might then just enable US, Germany and that's it |
Fix code scanning alerts IONIDE-009 (alerts #1056-#1058, #1069-#1070, #1083) and IONIDE-002 (alerts #1065, #1072, #1181). - Add [<return: Struct>] to partial active patterns in BabelPrinter.fs and Python transforms to avoid heap allocation for option types - Replace [] postfix array syntax with the idiomatic 'array' postfix syntax in BabelPrinter.fs, Fable2Python.Util.fs, and Python.AST.fs Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

References #1082.
Because JS doesn't have a native function for this, we need to check if the
Dates UTC offset is equal to either the offset in January or in June.If a users time zone doesn't have DST, this function should always return
false.@alfonsogarciacaro where can I add tests for the
isDSTfunction?