Browse Source

修改k线为自动切换夏令时和冬令时

master
liaoxinyu 9 months ago
parent
commit
ce2503ec25
  1. 23
      static/chart_main/sevencoin.js
  2. 2
      wxcomponents/vant/search/index.vue

23
static/chart_main/sevencoin.js

@ -274,14 +274,33 @@ $(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);
// 返回调整后的日期对象
return adjustedDate;
}
// 判断日期是否在夏令时(简化的逻辑,实际应用中需要考虑更多的边界情况)
dateIsInEDT(date) {
const year = date.getUTCFullYear();
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());
return date >= start && date < end;
}
getResolutionTime() {
const resolution = this.TView.chart().resolution();
switch (resolution) {

2
wxcomponents/vant/search/index.vue

@ -48,7 +48,7 @@ VantComponent({
placeholderStyle: String,
actionText: {
type: String,
value: 'Cancel',
value: i18n.t('common.cancel'),
},
background: {
type: String,

Loading…
Cancel
Save