Conversation
|
Good catch, thanks! 📅 |
|
The second test is always failing for me locally for some reason, not sure why: |
|
That's really strange... Because it's the year and we use UTC so there no timezone taken into account here... What is the result you get when running the same code in your fsi ? |
|
@MangelMaxime The dotnet version prints 1, but the javascript version (i.e. fable-core/Date/year) consistently prints 2. |
|
@MangelMaxime If that helps, if I change the DateTimeKind to Local, it prints 1 for the year. Or if I change the month or the day to 2 or more, it prints 1 for the year. Confusing, I know. |
|
@ncave So this have something to do with the edge case. The date used for the tests is Can you please tell me the result of each line of this code on your machine ? (It's JavaScript code) I am trying to break down the code step by step to understand the situation. var d = new Date(Date.UTC(1, 0, 1, 0, 0, 0))
d.toString()
d.setFullYear(1)
d.toString()
d.getYear()
d.getUTCFullYear() |
|
@MangelMaxime Fixed in #1139. |
|
Ah thanks :) I love how |
…patterns - Replace unsafe `.Value` on option types with safe pattern matching in Python/Replacements.fs (#1203) and Rust/Fable2Rust.fs (#1126, #1127) - Add [<return: Struct>] to partial active patterns in Dart/Fable2Dart.fs (#1105, #1106), Dart/Replacements.fs (#1177), and Rust/Fable2Rust.fs (#1115, #1116, #1117, #1118, #1119, #1120, #1121, #1122, #1123, #1124) to reduce heap allocations Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
In JavaScript date have this behavior:
In F#, if you set a datetime via
Datetime(1, 1, 1)you want the year 1 and not 1901.