Time/Date types for use on the frontend. This provides the following equivalents:
| #time/date "2020-10-10" | java.time.LocalDate | goog.date.Date | | #time/time "05:30:45" | java.time.LocalTime | lambdaisland.deja-fu/LocalTime | | #time/date-time "2020-10-07T12:16:41.761088" | java.time.LocalDateTime | goog.date.DateTime |
For all of these we make sure the tagged reader literals are read correctly, and that values of these types print with these reader tags.
All times are "local", they don't carry timezone information.
We also implement an ad-hoc API here, adding things as we need them, making sure that these functions hide the details of these types. All date/time manipulation on the frontend should go through this namespace. Avoid calling properties/methods of concrete types directly, and avoid using js/Date.
Create a new local-date-time using the same syntax from goog.Date or js/Date: (local-date-time 2021 4 19 15 39 0 0)
Parse a time string: (parse-local-date-time "2021-01-01T23:59")
Get the current time: (local-date-time)
Adjust the seconds component: (assoc (local-date-time) :seconds 0)
Get the next day: (add-interval (local-date-time) {:hours 1})
Works well with threading: (-> (parse-local-date-time "2021-01-01T23:59") (assoc :seconds 0) (to-local-date))
Time/Date types for use on the frontend. This provides the following equivalents: | #time/date "2020-10-10" | java.time.LocalDate | goog.date.Date | | #time/time "05:30:45" | java.time.LocalTime | lambdaisland.deja-fu/LocalTime | | #time/date-time "2020-10-07T12:16:41.761088" | java.time.LocalDateTime | goog.date.DateTime | For all of these we make sure the tagged reader literals are read correctly, and that values of these types print with these reader tags. All times are "local", they don't carry timezone information. We also implement an ad-hoc API here, adding things as we need them, making sure that these functions hide the details of these types. All date/time manipulation on the frontend should go through this namespace. Avoid calling properties/methods of concrete types directly, and avoid using js/Date. Create a new local-date-time using the same syntax from goog.Date or js/Date: (local-date-time 2021 4 19 15 39 0 0) Parse a time string: (parse-local-date-time "2021-01-01T23:59") Get the current time: (local-date-time) Adjust the seconds component: (assoc (local-date-time) :seconds 0) Get the next day: (add-interval (local-date-time) {:hours 1}) Works well with threading: (-> (parse-local-date-time "2021-01-01T23:59") (assoc :seconds 0) (to-local-date))
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close