格式化的时间戳给出了奇怪的结果

问题描述 投票:0回答:0

我注意到图表柱上的时间戳偏移了 5 小时 40 分钟。我不明白为什么。起初我以为这是一个 GMT 问题,因为我是 GMT+8,并认为时间戳可能是 UTC。但后来我看到时间戳不是8小时的差异,而是5小时40分钟。 ????

此代码正在生成时间戳:

indicator("GT Pivot Time", overlay=true)
myoffset = input(title="Offset?", defval=100)

ph = ta.pivothigh(myoffset, myoffset)
pl = ta.pivotlow(myoffset, myoffset)


drawLabel(_offset, _pivot, _style, _color) =>

    theTime = na(pl) ? str.tostring(ph) + "\n" + str.format_time(time, 'M/d') + "\n" + str.format_time(time, 'H:mm') : str.tostring(pl) + "\n" + str.format_time(time, 'M/d') + "\n" + str.format_time(time, 'H:mm') 
    if _pivot
        label.new(bar_index[_offset], _pivot, theTime, style=_style, color=_color, textcolor=color.white, size=size.small)

drawLabel(myoffset, ph, label.style_label_down, color.new(color.navy,10))
drawLabel(myoffset, pl, label.style_label_up, color.new(color.red,10))  

更奇怪的是,当我尝试将“GMT+8”添加到 str.format.time 代码时,格式化时间没有像预期的那样改变 8 小时,而是 10 小时! - 仍然有很大差距

有什么想法吗?

pine-script-v5
© www.soinside.com 2019 - 2024. All rights reserved.