Skip to content

Commit

Permalink
bye moment
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenruidigao committed Jan 12, 2025
1 parent e17d2ae commit 079e566
Show file tree
Hide file tree
Showing 14 changed files with 46 additions and 34 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"connect-redis": "^3.4.0",
"cookie-parser": "~1.4.3",
"cropperjs": "^1.5.12",
"dayjs": "^1.11.13",
"debug": "^3.1.0",
"discord-webhook-node": "^1.1.8",
"dotenv": "^5.0.1",
Expand Down Expand Up @@ -107,7 +108,6 @@
"husky": "^3.1.0",
"jest": "^24.1.0",
"jest-cli": "^24.1.0",
"moment": "^2.18.1",
"node-notifier": "^5.1.2",
"node-sass": "^7.0.3",
"npm-run-all": "^4.1.5",
Expand Down
11 changes: 7 additions & 4 deletions scripts/assignHashuidsToPlayers.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
const mongoose = require('mongoose');
const Game = require('../models/game');
const moment = require('moment');
const dayjs = require('dayjs');
const localizedFormat = require('dayjs/plugin/localizedFormat');
const _ = require('lodash');
const fs = require('fs');
const labels = [];
const data = {};
const { CURRENTSEASONNUMBER } = require('../src/frontend-scripts/node-constants');

dayjs.extend(localizedFormat);

const allPlayerGameData = {
fascistWinCount: 0,
totalGameCount: 0,
Expand Down Expand Up @@ -70,13 +73,13 @@ Game.find({})
.eachAsync(game => {
const playerCount = game.losingPlayers.length + game.winningPlayers.length;
const fascistsWon = game.winningTeam === 'fascist';
const gameDate = moment(new Date(game.date)).format('l');
const gameDate = dayjs(new Date(game.date)).format('l');
const rebalanced = (game.rebalance6p && playerCount === 6) || (game.rebalance7p && playerCount === 7) || (game.rebalance9p && playerCount === 9);
const rebalanced9p2f = game.rebalance9p2f && playerCount === 9;

if (
gameDate === '5/13/2017' ||
gameDate === moment(new Date()).format('l') ||
gameDate === dayjs(new Date()).format('l') ||
(rebalanced &&
playerCount === 9 &&
(gameDate === '10/29/2017' || gameDate === '10/30/2017' || gameDate === '10/31/2017' || gameDate === '11/1/2017' || gameDate === '11/2/2017'))
Expand Down Expand Up @@ -218,7 +221,7 @@ Game.find({})
allPlayerGameData.fascistWinCountSeason++;
}
}
labels.push(moment(new Date(game.date)).format('l'));
labels.push(dayjs(new Date(game.date)).format('l'));
})
.then(() => {
const uLabels = _.uniq(labels),
Expand Down
9 changes: 6 additions & 3 deletions scripts/retrieveGameData.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
const mongoose = require('mongoose');
const Game = require('../models/game');
const moment = require('moment');
const dayjs = require('dayjs');
const localizedFormat = require('dayjs/plugin/localizedFormat');
const fs = require('fs');
const data = {};
const { CURRENTSEASONNUMBER } = require('../src/frontend-scripts/node-constants');

dayjs.extend(localizedFormat);

const allPlayerGameData = {
fascistWinCount: 0,
totalGameCount: 0,
Expand Down Expand Up @@ -68,13 +71,13 @@ Game.find({})
.eachAsync(game => {
const playerCount = game.losingPlayers.length + game.winningPlayers.length;
const fascistsWon = game.winningTeam === 'fascist';
const gameDate = moment(new Date(game.date)).format('l');
const gameDate = dayjs(new Date(game.date)).format('l');
const rebalanced = (game.rebalance6p && playerCount === 6) || (game.rebalance7p && playerCount === 7) || (game.rebalance9p && playerCount === 9);
const rebalanced9p2f = game.rebalance9p2f && playerCount === 9;

if (
gameDate === '5/13/2017' ||
gameDate === moment(new Date()).format('l') ||
gameDate === dayjs(new Date()).format('l') ||
(rebalanced &&
playerCount === 9 &&
(gameDate === '10/29/2017' || gameDate === '10/30/2017' || gameDate === '10/31/2017' || gameDate === '11/1/2017' || gameDate === '11/2/2017'))
Expand Down
9 changes: 6 additions & 3 deletions src/frontend-scripts/components/section-main/GamesList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ import React from 'react'; // eslint-disable-line
import DisplayLobbies from './DisplayLobbies.jsx';
import PropTypes from 'prop-types';
import { Checkbox } from 'semantic-ui-react';
import moment from 'moment';
import dayjs from 'dayjs';
import duration from 'dayjs/plugin/duration';
import { CURRENT_SEASON_NUMBER, CURRENT_SEASON_END } from '../../constants';
import { Message } from 'semantic-ui-react';
import { processEmotes } from '../../emotes';

dayjs.extend(duration);

export class GamesList extends React.Component {
state = {
filtersVisible: false
Expand Down Expand Up @@ -254,8 +257,8 @@ export class GamesList extends React.Component {
<section className={this.state.filtersVisible ? 'browser-container' : 'browser-container filters-hidden'}>
<a href="#/changelog">
<h5 title="A season is an optional new tier of elo that is reset every 3 months.">
{moment(new Date()) > CURRENT_SEASON_END - moment.duration(1, 'month')
? `Season ends ${moment(CURRENT_SEASON_END).fromNow()}.`
{dayjs(new Date()) > CURRENT_SEASON_END - dayjs.duration(1, 'month')
? `Season ends ${dayjs(CURRENT_SEASON_END).fromNow()}.`
: `Welcome to season ${CURRENT_SEASON_NUMBER}!`}
</h5>
</a>
Expand Down
4 changes: 2 additions & 2 deletions src/frontend-scripts/components/section-main/Leaderboards.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import moment from 'moment';
import dayjs from 'dayjs';

class Leaderboard extends React.Component {
constructor() {
Expand Down Expand Up @@ -132,7 +132,7 @@ class Leaderboard extends React.Component {
<p>
<a href={`#/profile/${user.userName}`}>{user.userName}</a>
</p>
<p>{moment(user.date).format('DD-MM-YYYY')}</p>
<p>{dayjs(user.date).format('DD-MM-YYYY')}</p>
</li>
))}
</ul>
Expand Down
4 changes: 2 additions & 2 deletions src/frontend-scripts/components/section-main/Moderation.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import moment from 'moment';
import dayjs from 'dayjs';
import $ from 'jquery';
import PropTypes from 'prop-types';
import classnames from 'classnames';
Expand Down Expand Up @@ -1315,7 +1315,7 @@ export default class Moderation extends React.Component {
.map((report, index) => (
<tr key={index}>
<td style={{ whiteSpace: 'nowrap' }}>{report.modUserName}</td>
<td style={{ whiteSpace: 'nowrap' }}>{moment(new Date(report.date)).format('YYYY-MM-DD HH:mm')}</td>
<td style={{ whiteSpace: 'nowrap' }}>{dayjs(new Date(report.date)).format('YYYY-MM-DD HH:mm')}</td>
<td style={{ width: '120px', minWidth: '120px' }}>{niceAction[report.actionTaken] ? niceAction[report.actionTaken] : report.actionTaken}</td>
<td style={{ whiteSpace: 'normal', wordWrap: 'break-word', maxWidth: '200px', minWidth: '120px' }}>{report.userActedOn}</td>
<td style={{ whiteSpace: 'nowrap' }}>{report.ip}</td>
Expand Down
4 changes: 2 additions & 2 deletions src/frontend-scripts/components/section-main/Profile.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { PLAYER_COLORS } from '../../constants';
import Swal from 'sweetalert2';
import $ from 'jquery';
import { Dropdown } from 'semantic-ui-react';
import moment from 'moment';
import dayjs from 'dayjs';
import CollapsibleSegment from '../reusable/CollapsibleSegment.jsx';
import UserPopup from '../reusable/UserPopup.jsx';
import { getBlacklistIndex, userInBlacklist } from '../../../../utils';
Expand Down Expand Up @@ -261,7 +261,7 @@ class ProfileWrapper extends React.Component {
onClick={() =>
Swal.fire({
title: x.title,
text: `${x.text || ''} Earned: ${moment(x.dateAwarded).format('MM/DD/YYYY HH:mm')}.`,
text: `${x.text || ''} Earned: ${dayjs(x.dateAwarded).format('MM/DD/YYYY HH:mm')}.`,
imageUrl: `../images/badges/${x.id.startsWith('eloReset') ? 'eloReset' : x.id}.png`,
imageWidth: 100
})
Expand Down
4 changes: 2 additions & 2 deletions src/frontend-scripts/components/section-main/Reports.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import moment from 'moment';
import dayjs from 'dayjs';
import PropTypes from 'prop-types';
import { Checkbox } from 'semantic-ui-react';

Expand Down Expand Up @@ -125,7 +125,7 @@ export default class Reports extends React.Component {
})
.map((report, index) => (
<tr key={index} style={{ background: report.isActive ? '#cdf9db' : '#708a78' }}>
<td>{moment(new Date(report.date)).format('YYYY-MM-DD HH:mm')}</td>
<td>{dayjs(new Date(report.date)).format('YYYY-MM-DD HH:mm')}</td>
<td>
<a href={report.gameUid ? `#/table/${report.gameUid}` : ''} style={{ textDecoration: 'underline' }}>
{report.gameUid && report.gameUid.substr(0, 5)}
Expand Down
2 changes: 1 addition & 1 deletion src/frontend-scripts/components/section-main/Settings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1219,7 +1219,7 @@ class Settings extends React.Component {
return <img src={this.state.isUploaded} />;
}

if (gameSettings && gameSettings.customCardback) {
if (gameSettings && gameSettings.customCardback && gameSettings.customCardback.fileExtension) {
return (
<div
className="current-cardback"
Expand Down
4 changes: 2 additions & 2 deletions src/frontend-scripts/components/section-main/Signups.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect, useState } from 'react';
import moment from 'moment';
import dayjs from 'dayjs';
import PropTypes from 'prop-types';
import Swal from 'sweetalert2';

Expand Down Expand Up @@ -110,7 +110,7 @@ const Signups = ({ socket }) => {
})
.map((report, index) => (
<tr key={index}>
<td>{moment(new Date(report.date)).format('YYYY-MM-DD HH:mm')}</td>
<td>{dayjs(new Date(report.date)).format('YYYY-MM-DD HH:mm')}</td>
<td>{report.userName}</td>
<td>{report.ip}</td>
<td>{report.type}</td>
Expand Down
4 changes: 2 additions & 2 deletions src/frontend-scripts/components/section-main/Tracks.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import EnactedPolicies from './EnactedPolicies.jsx';
import PropTypes from 'prop-types';
import { Popup } from 'semantic-ui-react';
import playSound from '../reusable/playSound.js';
import moment from 'moment';
import dayjs from 'dayjs';
import * as Swal from 'sweetalert2';

class Tracks extends React.Component {
Expand Down Expand Up @@ -655,7 +655,7 @@ class Tracks extends React.Component {
const showDate = () => {
if (gameInfo && gameInfo.general && gameInfo.general.date) {
// field only exists in replays
Swal.fire(`This game was played on ${moment(gameInfo.general.date)}`);
Swal.fire(`This game was played on ${dayjs(gameInfo.general.date)}`);
}
};

Expand Down
4 changes: 2 additions & 2 deletions src/frontend-scripts/components/section-right/Generalchat.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { PLAYER_COLORS, getBadWord } from '../../constants';
import PropTypes from 'prop-types';
import { renderEmotesButton, processEmotes } from '../../emotes';
import { Scrollbars } from 'react-custom-scrollbars';
import moment from 'moment';
import dayjs from 'dayjs';

export default class Generalchat extends React.Component {
defaultEmotes = ['ja', 'nein', 'blobsweat', 'wethink', 'limes'];
Expand Down Expand Up @@ -416,7 +416,7 @@ export default class Generalchat extends React.Component {
: PLAYER_COLORS(user, !(gameSettings && gameSettings.disableSeasonal), 'chat-user');

if (userInfo.gameSettings && userInfo.gameSettings.enableTimestamps) {
timestamp = <span className="timestamp">{moment(chat.time).format('HH:mm')} </span>;
timestamp = <span className="timestamp">{dayjs(chat.time).format('HH:mm')} </span>;
}

return (
Expand Down
9 changes: 6 additions & 3 deletions src/frontend-scripts/constants.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
const cn = require('classnames');
const moment = require('moment');
const dayjs = require('dayjs');
const duration = require('dayjs/plugin/duration');

dayjs.extend(duration);

export const TOU_CHANGES = [
{
Expand Down Expand Up @@ -37,8 +40,8 @@ export const TOU_CHANGES = [
}
];

export const CURRENT_SEASON_NUMBER = 22 + Math.ceil((moment() - moment('2025-01-01T00:00:00.000Z')) / moment.duration(3, 'months'));
export const CURRENT_SEASON_END = moment('2025-01-01T00:00:00.000Z') + (CURRENT_SEASON_NUMBER - 22) * moment.duration(3, 'months');
export const CURRENT_SEASON_NUMBER = 22 + Math.ceil((dayjs() - dayjs('2025-01-01T00:00:00.000Z')) / dayjs.duration(3, 'months'));
export const CURRENT_SEASON_END = dayjs('2025-01-01T00:00:00.000Z') + (CURRENT_SEASON_NUMBER - 22) * dayjs.duration(3, 'months');

const ALPHANUMERIC = [...'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'];
const SYMBOLS = [...' -_=+!"£$%^&*()\\/.,<>?#~\'@;:[]{}'];
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4045,6 +4045,11 @@ date-fns@^1.30.1:
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-1.30.1.tgz#2e71bf0b119153dbb4cc4e88d9ea5acfb50dc05c"
integrity sha512-hBSVCvSmWC+QypYObzwGOd9wqdDpOt+0wl0KbU+R+uuZBS1jN8VsD1ss3irQDknRj5NvxiTF6oj/nDRnN/UQNw==

dayjs@^1.11.13:
version "1.11.13"
resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.11.13.tgz#92430b0139055c3ebb60150aa13e860a4b5a366c"
integrity sha512-oaMBel6gjolK862uaPQOVTA7q3TZhuSvuMQAAglQDOWYO9A91IrAOUJEyKVlqJlHE0vq5p5UXxzdPfMH/x6xNg==

debug@2, [email protected], debug@^2.2.0, debug@^2.3.3, debug@~2.6.0, debug@~2.6.4, debug@~2.6.6:
version "2.6.9"
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"
Expand Down Expand Up @@ -8598,11 +8603,6 @@ mkdirp@^1.0.3, mkdirp@^1.0.4:
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e"
integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==

moment@^2.18.1:
version "2.30.1"
resolved "https://registry.yarnpkg.com/moment/-/moment-2.30.1.tgz#f8c91c07b7a786e30c59926df530b4eac96974ae"
integrity sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how==

[email protected]:
version "3.6.12"
resolved "https://registry.yarnpkg.com/mongodb/-/mongodb-3.6.12.tgz#a8c152ae0c6c953b88d3b03714e2b885d6c2cae4"
Expand Down

0 comments on commit 079e566

Please sign in to comment.