-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
After setting the time zone (not the default time zone), there is an issue with displaying daylight saving time #49586
Comments
We need to fix it on the tikv side. Observations:
There are two possible reason, one is that tikv coprocessor does not handle the ConvertTimeZone correctly. |
use |
After investigation, the problem is TiKV is handling this date time incorrectly. The code below reproduces how TiKV deal with this date time: use chrono::{TimeZone, NaiveDate, DateTime};
fn chrono_datetime<T: TimeZone>(
time_zone: &T,
year: u32,
month: u32,
day: u32,
hour: u32,
minute: u32,
second: u32,
micro: u32,
) -> DateTime<T> {
// NOTE: We are not using `tz::from_ymd_opt` as suggested in chrono's README due
// to chronotope/chrono-tz #23.
// As a workaround, we first build a NaiveDate, then attach time zone
// information to it.
NaiveDate::from_ymd_opt(year as i32, month, day)
.and_then(|date| date.and_hms_opt(hour, minute, second))
.and_then(|t| t.checked_add_signed(chrono::Duration::microseconds(i64::from(micro))))
.and_then(|datetime| time_zone.from_local_datetime(&datetime).earliest())
.unwrap()
}
fn main() {
use std::str::FromStr;
let utc = chrono_datetime(&chrono_tz::UTC, 2023, 11, 30, 17, 2, 0, 0);
let tz = chrono_tz::Tz::from_str("Brazil/East").ok().unwrap();
let timestamp = tz.from_utc_datetime(&utc.naive_utc());
let naive_local = timestamp.naive_local();
println!("time={:?}", naive_local);
} When using the current TiKV's dependency: [dependencies]
chrono = "0.4.11"
chrono-tz = "=0.5.1" We will get the wrong result you observed:
Use a newer dependency version could fix it: [dependencies]
chrono = "0.4.11"
chrono-tz = "=0.5.3" We will get a correct result:
|
DST is no longer used in Brazil since 2020 [ref]. Updating chrono-tz from 0.5.1 to 0.5.2 bumps the timezone database from 2018i to 2020a, which includes this change, thus fixes the issue. Update: There are several news indicating that Brazil is considering bring back DST [ref(Chinese)] [ref(Chinese)] so that we need to keep track on the time zone updates in future. See TZ changelog: https://data.iana.org/time-zones/tzdb/NEWS |
…16221) ref #16220, close pingcap/tidb#49586 Brazil no longer observes DST since 2020[1]. Updating chrono-tz from 0.5.1 to 0.5.2 bumps the timezone database from 2018i to 2020a, which includes this change, thus fixes the issue. [1]: https://en.wikipedia.org/wiki/Daylight_saving_time_in_Brazil Signed-off-by: Neil Shen <[email protected]> Co-authored-by: Wenxuan <[email protected]>
…16221) (#16225) ref #16220, close pingcap/tidb#49586 Brazil no longer observes DST since 2020[1]. Updating chrono-tz from 0.5.1 to 0.5.2 bumps the timezone database from 2018i to 2020a, which includes this change, thus fixes the issue. [1]: https://en.wikipedia.org/wiki/Daylight_saving_time_in_Brazil Signed-off-by: Neil Shen <[email protected]> Co-authored-by: Neil Shen <[email protected]> Co-authored-by: Wenxuan <[email protected]>
In fact, #29427 is the same issue with this one. |
I agree that we should keep this issue open, as currently there are only workarounds. |
An individual issue would be better. Keeping this bug issue in an open state consistently will impact subsequent release actions. 😄 |
…16221) (#16227) ref #16220, ref pingcap/tidb#49586 Brazil no longer observes DST since 2020[1]. Updating chrono-tz from 0.5.1 to 0.5.2 bumps the timezone database from 2018i to 2020a, which includes this change, thus fixes the issue. [1]: https://en.wikipedia.org/wiki/Daylight_saving_time_in_Brazil Signed-off-by: Neil Shen <[email protected]> Co-authored-by: Neil Shen <[email protected]> Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com> Co-authored-by: Wenxuan <[email protected]>
…16221) (#16226) ref #16220, ref pingcap/tidb#49586 Brazil no longer observes DST since 2020[1]. Updating chrono-tz from 0.5.1 to 0.5.2 bumps the timezone database from 2018i to 2020a, which includes this change, thus fixes the issue. [1]: https://en.wikipedia.org/wiki/Daylight_saving_time_in_Brazil Signed-off-by: Neil Shen <[email protected]> Co-authored-by: Neil Shen <[email protected]> Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com> Co-authored-by: Wenxuan <[email protected]>
…16221) (#16224) ref #16220, ref pingcap/tidb#49586 Brazil no longer observes DST since 2020[1]. Updating chrono-tz from 0.5.1 to 0.5.2 bumps the timezone database from 2018i to 2020a, which includes this change, thus fixes the issue. [1]: https://en.wikipedia.org/wiki/Daylight_saving_time_in_Brazil Signed-off-by: Neil Shen <[email protected]> Co-authored-by: Neil Shen <[email protected]> Co-authored-by: Wenxuan <[email protected]>
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
2. What did you expect to see? (Required)
show right time
3. What did you see instead (Required)
show wrong time( The time display is 1 hour longer)
4. What is your TiDB version? (Required)
Problems were found during testing in the following versions: v6.5.3/6.5.6/7.1.2/7.5.0.
I estimate that all versions have issues
The text was updated successfully, but these errors were encountered: