Skip to content

Commit

Permalink
Use moment for timezones
Browse files Browse the repository at this point in the history
  • Loading branch information
sam-hu committed Jan 8, 2024
1 parent 834b087 commit 4495cbc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion netlify/functions/parse-nyt-by-id/parse-nyt-by-id.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable import/prefer-default-export */
import { Handler } from '@netlify/functions';
import axios from 'axios';
import moment from 'moment';
import {
ConnectionsGame, getDateByOffset, toInt,
} from '../../../src/Connections/utils';
Expand Down Expand Up @@ -32,7 +33,7 @@ export const handler: Handler = async (event) => {

const GetAndParseGame = async (id: number): Promise<ConnectionsGame> => {
const date = getDateByOffset(id - 1);
const formattedDate = date.toISOString().substring(0, 10);
const formattedDate = moment(date).format('YYYY-MM-DD');
const response = await axios.get(`https://www.nytimes.com/svc/connections/v1/${formattedDate}.json`);
return ParseGame(response.data);
};
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"firebase": "^10.6.0",
"human-id": "^4.1.0",
"js-base64": "^3.7.5",
"moment": "^2.30.1",
"papaparse": "^5.4.1",
"react": "^18.2.0",
"react-beautiful-dnd": "^13.1.1",
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3086,6 +3086,11 @@ minimist@^1.2.0, minimist@^1.2.6:
resolved "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz"
integrity sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==

moment@^2.30.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 "2.1.2"
resolved "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz"
Expand Down

0 comments on commit 4495cbc

Please sign in to comment.