Skip to content

Commit d3cbc42

Browse files
author
Nitro
committed
Timezone fixed.
1 parent 9b8e7ba commit d3cbc42

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# CafeAPI - Backend
22
This is a node.js + express.js + MongoDB api that counts votes. The votes represent the students opinions of the schools meals. Showing the opinions surrounding the food allows students to judge if the meal is worth going to.
33

4+
ver: v2.0.3
5+
46
# Requests and Responses
57

68
## Vote

src/index.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Backend Ver: v2.0.1
1+
// Backend Ver: v2.0.3
22

33
// Importing Environmental Variables
44
if (process.env.NODE_ENV !== 'production') {
@@ -32,7 +32,7 @@ const {
3232
isComment
3333
} = require('./modules/valid')
3434

35-
const debug = false
35+
const debug = true
3636

3737
// Initializing App
3838
const app = express()
@@ -51,7 +51,7 @@ app.use(bodyParser.urlencoded({ extended: true }))
5151
/* VOTE */
5252
app.post('/vote', async (req, res) => {
5353
// Getting parameters from API
54-
let date = new Date(moment(req.body.date).format('YYYY-MM-DD'))
54+
let date = new Date(moment(req.body.date).tz('America/New_York').format('YYYY-MM-DD'))
5555
let meal = req.body.meal
5656
let email = req.body.email
5757
let rate = req.body.rate
@@ -99,8 +99,8 @@ app.post('/vote', async (req, res) => {
9999
})
100100

101101
app.get('/vote', async (req, res) => {
102-
let date1 = new Date(moment(req.query.date1).format('YYYY-MM-DD'))
103-
let date2 = new Date(moment(req.query.date2).format('YYYY-MM-DD'))
102+
let date1 = new Date(moment(req.query.date1).tz('America/New_York').format('YYYY-MM-DD'))
103+
let date2 = new Date(moment(req.query.date2).tz('America/New_York').format('YYYY-MM-DD'))
104104

105105
if (debug) {
106106
console.log(date1)
@@ -123,7 +123,7 @@ app.get('/vote', async (req, res) => {
123123

124124
/* COMMENT */
125125
app.post('/comment', async (req, res) => {
126-
let date = new Date(moment(req.body.date).format('YYYY-MM-DD')) // Date
126+
let date = new Date(moment(req.body.date).tz('America/New_York').format('YYYY-MM-DD')) // Date
127127
let name = req.body.name // string
128128
let email = req.body.email //string
129129
let pw = req.body.pw // MD5 string 4a7d1ed414474e4033ac29ccb8653d9b
@@ -235,8 +235,8 @@ app.post('/delete_comment', async (req, res) => {
235235
})
236236

237237
app.get('/comment', async (req, res) => {
238-
let date1 = new Date(moment(req.query.date1).format('YYYY-MM-DD'))
239-
let date2 = new Date(moment(req.query.date2).format('YYYY-MM-DD'))
238+
let date1 = new Date(moment(req.query.date1).tz('America/New_York').format('YYYY-MM-DD'))
239+
let date2 = new Date(moment(req.query.date2).tz('America/New_York').format('YYYY-MM-DD'))
240240

241241
if (debug) {
242242
console.log(date1)

0 commit comments

Comments
 (0)