You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
在第一個情況可以看到因為多寫了 -0400,因此new Date()解析後,把時區差也給算上了,但後續的fixOffset為了補上時間差,反而造成了跟 moment 不一樣的結果,因為 moment 有多一層確認。
在第二種情況,多寫了北京時區+0800,tz 第二個參數帶入美東時區,亦跟 moment 不一樣
並不是說全然跟 moment 一致就是對的
只是好奇的是,這是故意被設計成這樣的嗎,或是其中有什麼概念在裡頭,想了解。
感謝
The text was updated successfully, but these errors were encountered:
FPNL
changed the title
Behavior question, Timezone. First parameter in tz() already wrote timezone?
Behavior question, Timezone. First parameter in tz() already wrote timezone? 關於時區的行為問題
Mar 31, 2021
Hi,
Updated#1
I found out
dayjs.tz()
do it on purpose, for the reason. Sodayjs.tz()
doesn't support first parameter with timezone.dayjs/src/plugin/timezone/index.js
Line 3 in 9c20e77
Q1
If first parameter have been added -0400, matched timezone Etc/GMT+4
should function
fixOffset
be called?In moment,
I've add -0400 in moment.tz, it will check needsOffset(), which return false for m._tzm is -240.
https://github.com/moment/moment-timezone/blob/ffc41900fed9efa9a31e87f0eadd66ec86b5046a/moment-timezone.js#L564
Q2
And there is one other situation, time with different timezone.
question is
How would it be designed in dayjs?
=====
你好,
假設系統是北京時間。
在第一個情況可以看到因為多寫了 -0400,因此
new Date()
解析後,把時區差也給算上了,但後續的fixOffset
為了補上時間差,反而造成了跟 moment 不一樣的結果,因為 moment 有多一層確認。在第二種情況,多寫了北京時區+0800,tz 第二個參數帶入美東時區,亦跟 moment 不一樣
並不是說全然跟 moment 一致就是對的
只是好奇的是,這是故意被設計成這樣的嗎,或是其中有什麼概念在裡頭,想了解。
感謝
The text was updated successfully, but these errors were encountered: