From 0411c0a431d61b62634713975110cc123d314bd4 Mon Sep 17 00:00:00 2001 From: buzz-lightsnack-2007 <73412182+buzz-lightsnack-2007@users.noreply.github.com> Date: Thu, 10 Apr 2025 22:50:58 +0800 Subject: [PATCH] add date string converter --- scripts/response/activity.JS | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/scripts/response/activity.JS b/scripts/response/activity.JS index 86dbb8f..bb5e349 100644 --- a/scripts/response/activity.JS +++ b/scripts/response/activity.JS @@ -7,13 +7,29 @@ class Activity extends DBParser { @param {Object} ENTRY the selected entry, or the entries */ constructor(ENTRY) { - super(DATA, { + super(ENTRY, { "_id": "ID", "username": "username", "description": "description", "duration": "duration", "date": "date" }); + + this.convert_date(); + }; + + /* + Convert the date to the needed format. + + @param {Date} DATE the target date + @return {String} the date + */ + convert_date(DATE) { + if (DATE || this.data.date) { + this.date = (new Date(DATE || this.data.date)).toDateString(); + + return (this.date); + } } }