Browse Source

修改币币时间自动化转时间

master
liaoxinyu 9 months ago
parent
commit
f673adbf8a
  1. 32
      pages/exchange/time-sharing.vue

32
pages/exchange/time-sharing.vue

@ -101,10 +101,40 @@ export default {
break;
}
},
isDSTByRules() {
const now = new Date();
const year = now.getUTCFullYear();
// 3 2:00 AM EDT
const dstStart = this.getNthSunday(year, 2, 2, 2); // 0 2=3
// 11 2:00 AM EST
const dstEnd = this.getNthSunday(year, 10, 1, 2); // 0 10=11
return now >= dstStart && now < dstEnd;
},
// nm0
getNthSunday(year, month, occurrence, hour) {
let date = new Date(year, month, 1);
let count = 0;
while (true) {
if (date.getDay() === 0) {
if (++count === occurrence) {
date.setHours(hour);
return date;
}
}
date.setDate(date.getDate() + 1);
}
},
intiChart($box) {
let timeData = this.isDSTByRules()
highstock.setOptions({
global: {
timezoneOffset: 4 * 60,
timezoneOffset: timeData ? 16 * 60 : 17 * 60,
},
});

Loading…
Cancel
Save