-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Description
We have a datatype to store time, under time.Time, however, there are plenty of places where we need to store only Date, without having to store Time information, For example: Date of Birth, College opening date, release date, etc.
Many databases provide fields to store Date alone. For example, Postgres has date type https://www.postgresql.org/docs/9.1/static/datatype-datetime.html; Mysql has DATE type https://dev.mysql.com/doc/refman/5.7/en/datetime.html
Javascript has input types for <input type="date"> which shows a datepicker which can be used for Date input. Demo: https://www.w3schools.com/html/tryit.asp?filename=tryhtml_input_date
If a web application has a date input field, the javascript front end can show dates, the database can save dates, but just for the sake of the Golang backend server, we are forced to write a custom Golang type that receives a string from the JS frontend, converts the string into a time.Time struct and then again, trim the time while storing into the database. A js frontend and a db backend can handle Date type natively, while a Golang backend could not.
I propose that we add native support for a date package or a time.Date struct. In case, we choose the latter approach, we need to break the API by removing the existing time.Date() function, which even though called as a "Date" function, accepts "hours, minutes, seconds, nanoseconds and Locations" as input parameters. I propose this for Go 2.