diff --git a/static/chart_main/sevencoin.js b/static/chart_main/sevencoin.js index 7fa08ee..29ed30e 100644 --- a/static/chart_main/sevencoin.js +++ b/static/chart_main/sevencoin.js @@ -277,8 +277,17 @@ $(function () { adjustToEasternTime(date) { let timestamp; - // 调整时间为美国东部时间 - timestamp = date - (-28800000)+(new Date(new Date().getTime()).getTimezoneOffset()* 60 * 1000) - 46800000; + // 判断日期是否在夏令时 + const dates = new Date(date); + const isInEDT = this.dateIsInEDT(dates); + // 根据是否在夏令时来调整时间 + if (isInEDT) { + // 在夏令时期间 + timestamp = date - (-28800000)+(new Date(new Date().getTime()).getTimezoneOffset()* 60 * 1000) - 43200000; // 使用43200000毫秒 = 12小时 + } else { + // 在冬令时期间 + timestamp = date - (-28800000)+(new Date(new Date().getTime()).getTimezoneOffset()* 60 * 1000) - 46800000; // 使用46800000毫秒 = 13小时 + } // 创建新的日期对象,并使用调整后的时间戳 const adjustedDate = new Date(timestamp); @@ -288,9 +297,8 @@ $(function () { // 判断日期是否在夏令时(简化的逻辑,实际应用中需要考虑更多的边界情况) dateIsInEDT(date) { const year = date.getUTCFullYear(); - const start = new Date(Date.UTC(year, 2, 13, 7)); // March, 2nd Sunday - const end = new Date(Date.UTC(year, 10, 6, 6)); // November, 1st Sunday - + const start = new Date(Date.UTC(year, 2, 8, 18)); // March, 2nd Sunday + const end = new Date(Date.UTC(year, 10, 3, 18)); // November, 1st Sunday start.setUTCDate(14 - start.getUTCDay()); end.setUTCDate(7 - end.getUTCDay());