Browse Source

修改k线时间固定到美国时区

master
liaoxinyu 1 year ago
parent
commit
6e22d30919
  1. 30
      static/chart_main/sevencoin.js

30
static/chart_main/sevencoin.js

@ -233,9 +233,8 @@ $(function () {
}
let zhangdiefu=(bar.close-bar.open)/bar.open
let zhangdiee=bar.close-bar.open
const times = new Date().toLocaleString("en-US", {timeZone: "America/New_York", hour: 'numeric', minute: 'numeric', hour12: false});
// tvQuoter.find('[data-name="date"]').text(this.timestampToTime(bar.time));
tvQuoter.find('[data-name="date"]').text(times);
tvQuoter.find('[data-name="date"]').text(this.timestampToTime(bar.time));
tvQuoter.find('[data-name="date_lang"]').text(this.lang=='zh-CN'?'时间':'Date');
tvQuoter.find('[data-name="open"]').text(bar.open);
tvQuoter.find('[data-name="open_lang"]').text(this.lang=='zh-CN'?'开':'Open');
@ -255,10 +254,9 @@ $(function () {
tvQuoter.find('[data-name="zhangdiee"]').css('color',zhangdiee>0?'#53b987':'#eb4d5c');
}
timestampToTime(timestamp) {
const thirteenHoursMs = 13 * 3600 * 1000;//修改时间只需要修改 那个13就行了
const adjustedTimestamp = timestamp - thirteenHoursMs;
// const adjustedTimestamp = timestamp;
const date = new Date(adjustedTimestamp);
const dates = new Date(timestamp);
const date = this.adjustToEasternTime(dates);
const yyyy = `${date.getFullYear()}`;
const yy = `${date.getFullYear()}`.substr(2);
const MM = `0${date.getMonth() + 1}`.slice(-2);
@ -276,6 +274,24 @@ $(function () {
}
return dateStr
}
adjustToEasternTime(date) {
// 将给定日期转换为时间戳
const timestamp = date.getTime();
// 获取美国东部时区偏移值(以分钟为单位)
const easternOffset = -240; // 美国东部时区偏移值为 -240 分钟
// 调整时间为美国东部时间
const adjustedTime = timestamp - (date.getTimezoneOffset() + easternOffset) * 60 * 1000;
// 创建新的日期对象,并使用调整后的时间戳
const adjustedDate = new Date(adjustedTime);
// 返回调整后的日期对象
return adjustedDate;
}
getResolutionTime() {
const resolution = this.TView.chart().resolution();
switch (resolution) {

Loading…
Cancel
Save