Microsecond accurate status numbers

master
Bob Mottram 2019-07-01 14:10:17 +01:00
parent 832480ef47
commit 220c54ba7d
1 changed files with 3 additions and 1 deletions

View File

@ -239,7 +239,7 @@ def getStatusNumber() -> (str,str):
currTime=datetime.datetime.utcnow() currTime=datetime.datetime.utcnow()
daysSinceEpoch=(currTime - datetime.datetime(1970,1,1)).days daysSinceEpoch=(currTime - datetime.datetime(1970,1,1)).days
# status is the number of seconds since epoch # status is the number of seconds since epoch
statusNumber=str((daysSinceEpoch*24*60*60) + (currTime.hour*60*60) + (currTime.minute*60) + currTime.second) statusNumber=str(((daysSinceEpoch*24*60*60) + (currTime.hour*60*60) + (currTime.minute*60) + currTime.second)*1000000 + currTime.microsecond)
published=currTime.strftime("%Y-%m-%dT%H:%M:%SZ") published=currTime.strftime("%Y-%m-%dT%H:%M:%SZ")
conversationDate=currTime.strftime("%Y-%m-%d") conversationDate=currTime.strftime("%Y-%m-%d")
return statusNumber,published return statusNumber,published
@ -310,6 +310,8 @@ def createPostBase(baseDir: str,username: str, domain: str, port: int,toUrl: str
newPost['cc']=ccUrl newPost['cc']=ccUrl
newPost['object']['cc']=ccUrl newPost['object']['cc']=ccUrl
if saveToFile: if saveToFile:
if ':' in domain:
domain=domain.split(':')[0]
outboxDir = createOutboxDir(username,domain,baseDir) outboxDir = createOutboxDir(username,domain,baseDir)
filename=outboxDir+'/'+newPostId.replace('/','#')+'.json' filename=outboxDir+'/'+newPostId.replace('/','#')+'.json'
with open(filename, 'w') as fp: with open(filename, 'w') as fp: