Skip to content

Commit d1a52fc

Browse files
committed
Getting cheatsheet updated.
1 parent d2f993e commit d1a52fc

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

docs/cheatsheet.md

+42
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,48 @@ user> (dtype-fn/fixed-rolling-window 3 #(apply + %) test-data)
228228
(44 42 39 36 33 30 27 24 21 19)
229229
```
230230

231+
## Dates & Times
232+
233+
All of the constructors for the types are in `tech.v2.datatype.datetime`. All your
234+
favorite `java.time` types are there. If you are unfamiliar with these types
235+
please check out the [datetime docs](datetime.md). Also in that namespace are
236+
scalar conversions between the types and pack/unpack operations if you want to
237+
store some of your types in data somewhere as integers.
238+
239+
All of the operations you can do once you have one or more of these types are
240+
under `tech.v2.datatype.datetime.operations`. You can do things like
241+
`get-day` and `plus-days` in both scalar and vectorized formats:
242+
243+
```clojure
244+
user> (require '[tech.v2.datatype.datetime :as dtype-dt])
245+
nil
246+
user> (require '[tech.v2.datatype.datetime.operations :as dtype-dt-ops])
247+
nil
248+
user> (dtype-dt/zoned-date-time)
249+
250+
#object[java.time.ZonedDateTime 0x1474b1 "2020-03-31T15:36:03.063-06:00[America/Denver]"]
251+
user> (dtype-dt/local-date)
252+
#object[java.time.LocalDate 0x72875089 "2020-03-31"]
253+
user> (def ld (dtype-dt/local-date))
254+
#'user/ld
255+
user> (dtype-dt-ops/plus-days ld 1)
256+
#object[java.time.LocalDate 0x5df0f8e4 "2020-04-01"]
257+
user> (dtype-dt-ops/>= *1 ld)
258+
true
259+
user> (dtype-dt-ops/plus-days ld (range 10))
260+
[#object[java.time.LocalDate 0x3a3eec48 "2020-03-31"] #object[java.time.LocalDate 0x4e09d01c "2020-04-01"] #object[java.time.LocalDate 0x5149b47 "2020-04-02"] #object[java.time.LocalDate 0x1ecd0a66 "2020-04-03"] #object[java.time.LocalDate 0x535ce95b "2020-04-04"] #object[java.time.LocalDate 0x53d55a1c "2020-04-05"] #object[java.time.LocalDate 0x72ba3d82 "2020-04-06"] #object[java.time.LocalDate 0x4d28789 "2020-04-07"] #object[java.time.LocalDate 0x3070a079 "2020-04-08"] #object[java.time.LocalDate 0x498c09d1 "2020-04-09"]]
261+
user> (dtype-dt-ops/get-day-of-week *1)
262+
[2 3 4 5 6 7 1 2 3 ]
263+
user> (dtype-dt-ops/get-epoch-milliseconds ld)
264+
1585690858819
265+
user> (dtype-dt-ops/get-epoch-milliseconds
266+
(dtype-dt-ops/plus-days ld (range 10)))
267+
[1585690877710 1585777277710 1585863677711
268+
1585950077711 1586036477711 1586122877711
269+
1586209277711 1586295677711 1586382077711
270+
1586468477712]
271+
```
272+
231273

232274
## Tensors
233275

0 commit comments

Comments
 (0)