Skip to content
Open
Show file tree
Hide file tree
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
17 changes: 7 additions & 10 deletions server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"@google/generative-ai": "^0.14.1",
"cookie-parser": "^1.4.5",
"cors": "^2.8.5",
"dayjs": "^1.11.19",
"dotenv": "^10.0.0",
"express": "^4.18.2",
"express-fileupload": "^1.2.1",
Expand All @@ -28,7 +29,6 @@
"he": "^1.2.0",
"html-to-text": "^9.0.5",
"memorystore": "^1.6.6",
"moment": "^2.29.4",
"nanoid": "^3.1.31",
"node-fetch": "^2.7.0",
"nodemon": "^2.0.20",
Expand Down
28 changes: 14 additions & 14 deletions server/server/routing/db_routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const PDFDoc = require("pdfkit");
const fs = require("fs");
const fse = require("fs-extra");
const path = require("path");
const moment = require("moment");
const dayjs = require("dayjs");
const fileSizeParser = require("filesize-parser");
const he = require("he");
const { convert } = require("html-to-text");
Expand Down Expand Up @@ -298,7 +298,7 @@ module.exports = (db) => {

const active =
body.active === "false"
? moment().format(CONSTANTS.datetime_format)
? dayjs().format(CONSTANTS.datetime_format)
: "";

const viewOnly = body.viewOnly === "true" ? "TRUE" : "FALSE";
Expand Down Expand Up @@ -364,7 +364,7 @@ module.exports = (db) => {
user.type,
user.semester_group === "" ? null : user.semester_group,
user.active.toLocaleLowerCase() === "false"
? moment().format(CONSTANTS.datetime_format)
? dayjs().format(CONSTANTS.datetime_format)
: "",
defaultProfileInfo,
];
Expand Down Expand Up @@ -431,7 +431,7 @@ module.exports = (db) => {

const active =
body.active === "false"
? moment().format(CONSTANTS.datetime_format)
? dayjs().format(CONSTANTS.datetime_format)
: "";

const viewOnly = body.viewOnly === "true" ? "TRUE" : "FALSE";
Expand Down Expand Up @@ -919,7 +919,7 @@ module.exports = (db) => {
WHERE archive_id = ?`;
const inactive =
body.inactive === "true"
? moment().format(CONSTANTS.datetime_format)
? dayjs().format(CONSTANTS.datetime_format)
: "";

const locked =
Expand All @@ -928,7 +928,7 @@ module.exports = (db) => {
" " +
req.user.lname +
" locked at " +
moment().format(CONSTANTS.datetime_format)
dayjs().format(CONSTANTS.datetime_format)
: "";

const checkBox = (data) => {
Expand Down Expand Up @@ -998,15 +998,15 @@ module.exports = (db) => {
let body = req.body;
const inactive =
body.inactive === "true"
? moment().format(CONSTANTS.datetime_format)
? dayjs().format(CONSTANTS.datetime_format)
: "";
const locked =
body.locked === "true"
? req.user.fname +
" " +
req.user.lname +
" locked at " +
moment().format(CONSTANTS.datetime_format)
dayjs().format(CONSTANTS.datetime_format)
: "";

const updateArchiveQuery = `INSERT INTO ${DB_CONFIG.tableNames.archive}(featured, outstanding, creative,
Expand Down Expand Up @@ -1086,7 +1086,7 @@ module.exports = (db) => {
WHERE archive_id = ?`;
const inactive =
body.inactive === "true"
? moment().format(CONSTANTS.datetime_format)
? dayjs().format(CONSTANTS.datetime_format)
: "";

const locked =
Expand All @@ -1095,7 +1095,7 @@ module.exports = (db) => {
" " +
req.user.lname +
" locked at " +
moment().format(CONSTANTS.datetime_format)
dayjs().format(CONSTANTS.datetime_format)
: "";

let files_uploaded = [];
Expand Down Expand Up @@ -1256,15 +1256,15 @@ module.exports = (db) => {
let body = req.body;
const inactive =
body.inactive === "true"
? moment().format(CONSTANTS.datetime_format)
? dayjs().format(CONSTANTS.datetime_format)
: "";
const locked =
body.locked === "true"
? req.user.fname +
" " +
req.user.lname +
" locked at " +
moment().format(CONSTANTS.datetime_format)
dayjs().format(CONSTANTS.datetime_format)
: "";

const name = body.url_slug; //this value needs to be unique, but isn't used, so this is a relatively safe method.
Expand Down Expand Up @@ -3292,7 +3292,7 @@ module.exports = (db) => {

const date_deleted =
body.date_deleted === "false"
? moment().format(CONSTANTS.datetime_format)
? dayjs().format(CONSTANTS.datetime_format)
: "";
const parsedFileSize = body.file_size
? fileSizeParser(body.file_size)
Expand Down Expand Up @@ -3855,7 +3855,7 @@ module.exports = (db) => {

const date_deleted =
body.date_deleted === "false"
? moment().format(CONSTANTS.datetime_format)
? dayjs().format(CONSTANTS.datetime_format)
: "";
const parsedFileSize = body.file_size
? fileSizeParser(body.file_size)
Expand Down
23 changes: 0 additions & 23 deletions ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
"html-entities": "^2.5.2",
"html-react-parser": "^5.1.16",
"html-to-text": "^9.0.5",
"moment": "^2.30.1",
"moment-timezone": "^0.5.46",
"prop-types": "^15.8.1",
"react": "^18.3.1",
"react-csv": "^2.2.2",
Expand Down
12 changes: 7 additions & 5 deletions ui/src/components/Tabs/AdminTab/ContentEditor/FileManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { SecureFetch } from "../../../util/functions/secureFetch";
import FileBrowser from "react-keyed-file-browser";
import CustomItemDetail from "./CustomItemDetail";
import "react-keyed-file-browser/dist/react-keyed-file-browser.css";
import Moment from "moment";
import dayjs from "dayjs"

export default function FileManager() {
// Stores the data of files to display to front end
Expand Down Expand Up @@ -46,12 +46,13 @@ export default function FileManager() {
directory + pathData["file"] + "/",
newFilesToSet,
);
else
else {
newFilesToSet.push({
key: directory + pathData["file"],
modified: Moment(pathData["lastModified"]).toDate(),
modified: dayjs(pathData["lastModified"]).toDate(),
size: pathData["size"],
});
}
});
// Empty directory
} else {
Expand Down Expand Up @@ -79,12 +80,13 @@ export default function FileManager() {
fileData.forEach((pathData) => {
if (isDirectory(pathData["file"])) {
getFilesInDirectory(pathData["file"] + "/", newFilesToSet);
} else
} else {
newFilesToSet.push({
key: pathData["file"],
modified: Moment(pathData["lastModified"]).toDate(),
modified: dayjs(pathData["lastModified"]).toDate(),
size: pathData["size"],
});
}
});
if (newFilesToSet) setMyFiles(newFilesToSet);
}
Expand Down
29 changes: 20 additions & 9 deletions ui/src/components/util/functions/utils.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,44 @@
import moment from "moment-timezone";
import dayjs from "dayjs";
import _ from "lodash";
import { SERVER_TIMEZONE } from "./constants";
import { useState, useEffect } from "react";

// include plugins
var utc = require("dayjs/plugin/utc");
var timezone = require("dayjs/plugin/timezone");
var localizedFormat = require("dayjs/plugin/localizedFormat");

dayjs.extend(utc);
dayjs.extend(timezone);
dayjs.extend(localizedFormat);


export const parseDateNoOffset = (dateTime) => {
return moment(dateTime);
return dayjs(dateTime);
};

export const parseDate = (dateTime) => {
return parseMomentDate(dateTime).toDate();
return parseDayjsDate(dateTime).toDate();
};

const parseMomentDate = (dateTime) => {
let newTime = moment(dateTime).utcOffset(0, true);
return newTime.tz(SERVER_TIMEZONE);
const parseDayjsDate = (dateTime) => {
let newTime = dayjs(dateTime).utcOffset(0, true);
return dayjs.tz(newTime, SERVER_TIMEZONE);
};

export const formatDateTime = (dateTime) => {
let date = parseMomentDate(dateTime);
let date = parseDayjsDate(dateTime);
return `${date.format("L LT")}`;
};

export const formatDate = (date) => {
let dateObj = parseMomentDate(date);
let dateObj = parseDayjsDate(date);
return `${dateObj.format("L")}`;
};

export const formatDateNoOffset = (date) => {
return `${parseDateNoOffset(date).format("L")}`;
let dateObj = parseDateNoOffset(date);
return `${dateObj.format("L")}`;
};

// Month+1 in Date constructor to account for how it determines month from numbers
Expand Down