BitShares Forum
Main => Technical Support => Topic started by: litepresence on February 26, 2018, 03:16:16 pm
-
from bitshares.blockchain import Blockchain
import time
def dex(command):
if command == 'blocktime':
now = int(time.time())
chain = Blockchain(mode='head')
current_block = chain.get_current_block_num()
blocktime = chain.block_time(current_block)
blocktimestamp = chain.block_timestamp(current_block)
drift = now - blocktimestamp
drifthours = drift/3600
print ('block :', current_block)
print ('blocktime :', blocktime)
print ('stamp :', blocktimestamp)
print ('ctime(stamp) :', time.ctime(blocktimestamp))
print ('now :', now)
print ('ctime(now) :', time.ctime(now))
print ('drift seconds :', ('%s' % drift))
print ('drift hours :', ('%.2f' % drifthours))
return current_block, blocktimestamp, drift
dex('blocktime')
returns
block : 24764676
blocktime : 2018-02-26 15:03:48
stamp : 1519675428
ctime(stamp) : Mon Feb 26 15:03:48 2018
now : 1519657430
ctime(now) : Mon Feb 26 10:03:50 2018
drift seconds : -17998
drift hours : -5.00
はるか, [26.02.18 09:58]
It's a core bug?
Abit More, [26.02.18 09:58]
Timestamp Without tz
Abit More, [26.02.18 09:58]
But too late to fix
はるか, [26.02.18 09:58]
Timestamp should always be epoch I think
BTS litepresence1, [26.02.18 09:59]
from user perspective I agree
Abit More, [26.02.18 09:59]
When converted to or from String,lack of a z at the end
はるか, [26.02.18 10:00]
ah yes it's missing a Z
はるか, [26.02.18 10:00]
so it needs all clients to manually handle that...
Abit More, [26.02.18 10:00]
Py lib can add it
Abit More, [26.02.18 10:00]
Yes