Instants (RFC 3339) and duration protocol.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
(ns foo.baz
  (:api dunaj)
  (:require [dunaj.time :refer [calendar-instant-factory]]))

(instant "2003")
;;=> #<BasicInstant 2003-01-01T00:00:00.000000000+00:00>

(canonical (instant "2003"))
;;=> "2003-01-01T00:00:00.000000000+00:00"

(num (instant "2003"))
;;=> 1041379200000.000000M

(num (instant calendar-instant-factory "2003"))
;;=> 1041379200000

basic-instant-factory

Available since version 1.0 (view source)

not referred automatically

VAR of type IInstantFactory

A factory for basic instants.

See also: instant, IIntantFactory

calendar-instant-factory

Available since version 1.0 (view source)

not referred automatically

VAR of type IInstantFactory

A java.util.Calendar instant factory.

See also: instant, IIntantFactory

date-instant-factory

Available since version 1.0 (view source)

not referred automatically

VAR of type IInstantFactory

A java.util.Date instant factory.

See also: instant, IIntantFactory

default-instant-factory

Available since version 1.0 (view source)

not referred automatically

VAR of type clojure.lang.Var

A dynamic var holding default instant factory.

See also: instant, IIntantFactory

duration?

Available since version 1.0 (view source)

Usage:
  • (duration? x)

Type signature: Predicate

Returns true if object x satisfies IDuration protocol, false otherwise.

instant

Available since version 1.0 (view source)

Usage:
  • (instant val)

  • (instant factory val)

Type signatures:
  • (Any) → IInstant

  • (IInstantFactory ⨯ Any) → IInstant

Returns an instant from val, which is an instant or a string representing instant timestamp. Instant type is determined by factory. Default instant factory is stored in default-instant-factory var.

See also: instant?, now

instant?

Available since version 1.0 (view source)

Usage:
  • (instant? x)

Type signature: Predicate

Returns true if object x satisfies IInstant protocol, false otherwise.

milliseconds

Available since version 1.0 (view source)

Usage:
  • (milliseconds duration)

  • (milliseconds duration instant)

  • (milliseconds duration instant before?)

Type signatures:
  • ((U IDuration Integer+)) → Integer+

  • ((U IDuration Integer+) ⨯ IInstant) → Integer+

  • ((U IDuration Integer+) ⨯ IInstant ⨯ Boolean+) → Integer+

Returns number of milliseconds from duration relative to given start instant, which defaults to (now). If before? is true (defaults to false), uses instant as an end instant. Accepts integer in duration, and treats it as a number of milliseconds.

See also: nanoseconds, duration?

nanoseconds

Available since version 1.0 (view source)

Usage:
  • (nanoseconds duration)

  • (nanoseconds duration instant)

  • (nanoseconds duration instant before?)

Type signatures:
  • ((U IDuration Integer+)) → Integer+

  • ((U IDuration Integer+) ⨯ IInstant) → Integer+

  • ((U IDuration Integer+) ⨯ IInstant ⨯ Boolean+) → Integer+

Returns number of nanoseconds from duration relative to given start instant, which defaults to (now). If before? is true (defaults to false), uses instant as an end instant. Accepts integer in duration, and treats it as a number of milliseconds.

See also: milliseconds, duration?

now

Available since version 1.0 (view source)

Usage:
  • (now)

Type signature:
  • () → IInstant

Returns an instant representing current time.

See also: instant, instant?

timestamp-instant-factory

Available since version 1.0 (view source)

not referred automatically

VAR of type IInstantFactory

A java.sql.Timestamp instant factory.

See also: instant, IIntantFactory