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

Date format and internationalization #179

Open
ScreamZ opened this issue Aug 5, 2018 · 4 comments
Open

Date format and internationalization #179

ScreamZ opened this issue Aug 5, 2018 · 4 comments

Comments

@ScreamZ
Copy link

ScreamZ commented Aug 5, 2018

Hello, first I would like to thank you for this great library. I love it so much.

I think this is a pretty common issue, but I'm starting playing with date and locales :'(

Problem

If I'm posting today it's because I'm encountering an issue with apollo-client my GraphQL client library.

I'm using the DatePicker component with single mode, I'm currently in France and when I click a day it returns me the following value : Mon Aug 13 2018 00:00:00 GMT+0200 (Central European Summer Time)

apollo-client convert it to 2018-08-12T22:00:00.000Z before sending it to my backend. This is a standard 8601 conversion (ES2015 specification).

Result: When my backend receive and store the data. It is the day before. When I fetch back the data, there is no more localization because I'm getting the UTC ISO 8601 string.

So i'm highlighting the day before instead of the one I clicked.

Questions

Here come my two questions:

  1. What do you think should I store ? (I'm using a multi-country application). ISO 8601 ? Date with Locale ?
  2. How can I face this ?

Thanks for your help…
Best regards.

Andréas

@kl3sk
Copy link

kl3sk commented Aug 6, 2018

Maybe this is your apollo-client who needs to have the right locale.

@ScreamZ
Copy link
Author

ScreamZ commented Aug 6, 2018

@kl3sk : Seems that is not possible to configure on apollo-client.

What I've done atm is:

  1. Using the Mon Aug 13 2018 00:00:00 GMT+0200 (Central European Summer Time) format.
  2. Therefore I let apollo-client auto-convert it to UTC ISO8601.
  3. My database is storing the UTC format.
  4. My webservice is serving UTC Date.
  5. And client side I'm using moment to localize the date (I though v-calendar would have done this auto, seems not)
const localizedDate = moment(session.date);

Looks good, but I think the documentation would require a bit of light on this ?

Best regards

PS: @nathanreyes I ping you on this, just in case you have some time to share with us about that ;)

@premiermatt
Copy link

Having the same issue parsing a date. Some information in the docs would be appreciated.

@nathanreyes
Copy link
Owner

nathanreyes commented Feb 15, 2019

@ScreamZ Thanks for the well-written explanation. Just to be clear when you pass the session.date into v-date-picker, this is a string in ISO 8601 format?

EDIT: Ok, please disregard that. I think I did not understand your issue.

Question: When the client fetches the date from your web service, how were you providing this date value back to v-date-picker? What code were you using, before using moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants