Add DateTime writing support to SLMessages
There may be some value in providing a read version of this as well, but it is comprised of so many properties that I'm leaving that out for now. If it becomes a need in the future, it will be straightforward to add.
This commit is contained in:
@ -150,6 +150,21 @@ exports.SLMessage = class SLMessage extends SmartBuffer {
|
||||
return 0;
|
||||
}
|
||||
|
||||
writeSLDateTime(date) {
|
||||
this.writeInt16LE(date.getFullYear());
|
||||
this.writeInt16LE(date.getMonth() + 1);
|
||||
var dayOfWeek = date.getDay() - 1;
|
||||
if (dayOfWeek < 0) {
|
||||
dayOfWeek = 6;
|
||||
}
|
||||
this.writeInt16LE(dayOfWeek);
|
||||
this.writeInt16LE(date.getDate());
|
||||
this.writeInt16LE(date.getHours());
|
||||
this.writeInt16LE(date.getMinutes());
|
||||
this.writeInt16LE(date.getSeconds());
|
||||
this.writeInt16LE(date.getMilliseconds());
|
||||
}
|
||||
|
||||
static slackForAlignment(val) {
|
||||
return (4 - val % 4) % 4;
|
||||
}
|
||||
|
Reference in New Issue
Block a user