Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

和行程相關的日期不該需要擔心時區 #16

Closed
ychi opened this issue Feb 16, 2017 · 2 comments
Closed

和行程相關的日期不該需要擔心時區 #16

ychi opened this issue Feb 16, 2017 · 2 comments
Labels

Comments

@ychi
Copy link
Collaborator

ychi commented Feb 16, 2017

如果 client side 傳來的日期(比如入住日)是 javascript 的 Date, 其實裡面是有時區資訊的,萬一 server 的時區和 browser 時區不同可能會因為時差所以搞錯日期。

和行程相關的日期(比如入住日、用餐日)不該需要擔心時區,client side 應該只要傳字串('2017-05-01')或是一個物件(ex: {year: 2017, month: 5, day: 1}).

PostgreSQL 裡面其實有 date only 的資料型態,但是 js 端還沒有很好的對應,Sequelize 在下一個主要版本應該會處理這個問題:
sequelize/sequelize#4858
brianc/node-pg-types#50
brianc/node-pg-types#53

在那之前我們可以先討論個格式,在傳輸的時候不要傳 timestamp, 而是只傳年月日資訊

@ychi ychi added the question label Feb 16, 2017
@wesley100002001
Copy link
Owner

先簡單 echo,我同意純字串 yyyy-mm-dd

@ychi
Copy link
Collaborator Author

ychi commented Feb 16, 2017

good, it's also ISO format

@ychi ychi closed this as completed Feb 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants