Prisma1: Add a pure date field type

Created on 25 Jun 2017  路  5Comments  路  Source: prisma/prisma1

You can use DateTime to store dates like this 2017-06-25, which will be converted to 2017-06-25T00:00.000Z. As an addition to this, storing pure date fields would be nice so you don't have to think about timezones when displaying it: 2017-06-25 won't be converted.

statustale

Most helpful comment

Dates and datetimes are very different. A person wants to store their birthdate with the year, month, and day that they like, usually in the time zone in which they were born. DateTimes are instants. IT doesn't feel right to use a datetime for a birthdate field. Yeah it works if you "assume UTC and ignore H, M, S, and all the small fields...." Just feels dirty. A pure date time would be nice. In the meantime, storing year, month, and day works too. Dates and times are hard.

All 5 comments

I think a better solution would be a field argument 'format'. A date is a date, stored as a date. Formatting requirements should not creep into the storage model.

query {
   allPosts {
      title
      createdAt(format: "yyyy-MM-dd")
   }
} 

Great point, see also #91.

I know, I created https://github.com/graphcool/feature-requests/issues/240 before, so just taking the opportunity to make that point again :+1:

Dates and datetimes are very different. A person wants to store their birthdate with the year, month, and day that they like, usually in the time zone in which they were born. DateTimes are instants. IT doesn't feel right to use a datetime for a birthdate field. Yeah it works if you "assume UTC and ignore H, M, S, and all the small fields...." Just feels dirty. A pure date time would be nice. In the meantime, storing year, month, and day works too. Dates and times are hard.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 10 days if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ragnorc picture ragnorc  路  3Comments

Fi1osof picture Fi1osof  路  3Comments

MitkoTschimev picture MitkoTschimev  路  3Comments

jannone picture jannone  路  3Comments

AlessandroAnnini picture AlessandroAnnini  路  3Comments