提交 58531b81 编写于 作者: Huan (李卓桓)'s avatar Huan (李卓桓)

support both seconds & milliseconds timestamp

上级 c31c757b
......@@ -587,6 +587,7 @@ export class Message extends Accessory implements Sayable {
*/
public async recall (): Promise<boolean> {
log.verbose('Message', 'recall()')
const isSuccess = await this.puppet.messageRecall(this.id)
return isSuccess
}
......@@ -915,9 +916,24 @@ export class Message extends Accessory implements Sayable {
throw new Error('no payload')
}
// convert the unit timestamp to milliseconds
// (from seconds to milliseconds)
return new Date(1000 * this.payload.timestamp)
/**
* Huan(202001): support both seconds & milliseconds
*
* How to test if a given time-stamp is in seconds or milliseconds?
* https://stackoverflow.com/a/23982005/1123955
*/
let timestamp = this.payload.timestamp
/**
* 1e11:
* in milliseconds: Sat Mar 03 1973 09:46:39 UTC
* in seconds: Wed Nov 16 5138 9:46:40 UTC
*/
if (timestamp < 1e11) {
timestamp *= 1000 // turn seconds to milliseconds
}
return new Date(timestamp)
}
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册