Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store timestamp in the log #2732

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions rooms.js
Original file line number Diff line number Diff line change
Expand Up @@ -1037,6 +1037,9 @@ let BattleRoom = (() => {
logData.endType = this.battle.endType;
if (!p1rating) logData.ladderError = true;
const date = new Date();
logData.timestamp = date;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Um, JSON doesn't support storing dates. It will toJSON the date, which I believe makes it a string. Is that what you want, or do you want a numeric timestamp?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'm fine with strings. In theory this could introduce TZ issues, but I'd rather have readability. If you care, I'm fine with numeric, though.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, but you should probably do the conversion explicitly new Date().toString(), so future people who read your code know that it's intentional and not accidental.

logData.id = this.id;
logData.format = this.format;
const logsubfolder = Tools.toTimeStamp(date).split(' ')[0];
const logfolder = logsubfolder.split('-', 2).join('-');

Expand Down