vura.core

*calendar*

dynamic

Influences time->value and value->time functions as well as all '?' functions.
Valid values: 
:gregorian (default)
:julian
:islamic
:hebrew

*holiday?*

dynamic

This variable is supposed to be used through with-time-configuration
macro. Specify function that calculates if given day-context is
holiday or not. Look @ "day-context" Returns boolean

*offset*

dynamic

Variable that is used in function get-dst-offset. ->local, <-local and day? funcitons are affected
when changing value of this variable. I.E. (binding [*offset* (hours -2)] ...) would make all computations
in that offset from UTC.

*timezone*

dynamic

Variable that is used in function get-dst-offset. ->local, <-local and day? funcitons are affected
when changing value of this variable. I.E. (binding [*timezone* :hr] ...) would make all computations
in that time zone (offset).

*weekend-days*

dynamic

This variable can be used to customize weekend? function to
return true or false for day-context. Function should accept one
argument that is supposed to be day [1-7] and return true or false.

after

(after date value)
Returns Date object that was after some time value

before

(before date value)
Returns Date object that was before some time value

calendar-frame

multimethod

Returns sequence of days for given value that are contained in that frame-type. List is consisted
of keys:

 :value
 :day
 :week
 :month
 :day-in-month
 :weekend?
 :holiday?
 :first-day-in-month?
 :last-day-in-month?

 for Gregorian calendar. Frame types can be extened by implementing different calendar-frame functions.
 Vura supports calendar-frames for:
  * year
  * month
  * week

context->value

(context->value {:keys [year month day-in-month hour minute second millisecond], :or {year 0, month 1, day-in-month 1, hour 0, minute 0, second 0, millisecond 0}})
Function turns map of time units to value

date

(date)(date year)(date year month)(date year month day)(date year month day hour)(date year month day hour minute)(date year month day hour minute second)(date year month day' hour' minute' second' millisecond')
Constructs new Date object

date->utc-value

(date->utc-value date)

date->value

(date->value t)
Returns value of Date instance in seconds. Value is localized to offset

day

86400000

day-context

day-in-month?

(day-in-month? value)
Returns which day (Gregorian) in month input value belongs to. For example
for date 15.02.2015 it will return number 15

day-in-year?

(day-in-year? value)
Returns day in year period (1 - 366)

day-time-context

(day-time-context value)
Returns day context for given value in Gregorian calendar. 

Returnes hash-map with keys: 
  :value
  :millisecond
  :second
  :hour
  :day
  :week
  :month
  :year
  :day-in-month
  :weekend?
  :holiday?
  :first-day-in-month?
  :last-day-in-month?

day?

(day? value)
Returns which day in week does input value belongs to. For example
for date 15.02.2015 it will return number 7

days

(days n)
Function returns value of n days as number.

first-day-in-month

(first-day-in-month value)
Returns value of first day in current month

first-day-in-month?

(first-day-in-month? value)
Returns true if value in seconds belongs to first day in month.

get-dst-offset

(get-dst-offset value)
Returns DST offset for UTC input value

get-locale-timezone

get-timezone-locale

hour

3600000

hour?

(hour? value)
Returns which hour in day does input value belongs to. For example
for date 15.02.2015 it will return number 0

hours

(hours n)
Function returns value of n hours as number.

interval

(interval start end)
Returns period of time value in milliseconds between start and end. Input values
are supposed to be Date.

intervals

(intervals & timestamps)
Given sequence of timestamps (Date) values returns period values between each timestamp
value in milliseconds

last-day-in-month

(last-day-in-month value)
Returns value of last day in current month

last-day-in-month?

(last-day-in-month? value)
Returns true if value in seconds belongs to last day in month.

microsecond

1.0E-3

midnight

(midnight value)
Function calculates value of midnight for given value. For example
if some date value is inputed it will round-number to the begining of
that day.

millisecond

1

millisecond?

(millisecond? value)
Returns which millisecond in day does input value belongs to. For example
for date 15.02.2015 it will return number 0

milliseconds

(milliseconds n)
Function returns value of n seconds as number.

minute

60000

minute?

(minute? value)
Returns which hour in day does input value belongs to. For example
for date 15.02.2015 it will return number 0

minutes

(minutes n)
Function returns value of n minutes as number.

month?

(month? value)
Returns which month does input value belongs to. For example
for date 15.02.2015 it will return number 2

nanosecond

1.0E-6

period

(period {:keys [weeks days hours seconds minutes milliseconds], :or {weeks 0, days 0, hours 0, seconds 0, minutes 0, milliseconds 0}})
Returns number of seconds of all input arguments added together

period?

(period? value)
Returns duration of for input value in form of map with keys:

:weeks
:days
:hours
:minutes
:seconds
:milliseconds

round-number

(round-number number)(round-number number target-number)(round-number number target-number round-how)(round-number number target-number round-how? symetric?)
Function returns round number that is devidable by target-number.
Rounding strategy can be specified in round-how? options:

 :floor
 :ceil
 :up
 :down

Rounding number strategy is symetric to 0. This means that :ceil will round
negative numbers to lower target-number. I.E (round-number -9.5 1 :ceil) would return -10.
Rounding happens in absolute domain and sign is inserted afterwards.
 
Negative target-numbers are not supported. Can't reason about that yet. Maybe for imaginary numbers?

second

1000

second?

(second? value)
Returns which second in day does input value belongs to. For example
for date 15.02.2015 it will return number 0

seconds

(seconds n)
Function returns value of n seconds as number.

teleport

(teleport value timezone)
Teleports value to different timezone.

time-as-value

macro

(time-as-value bindings & body)
bindings => [name (time->value x) ...]

Similar to let or binding. Casts all bound symbol values with
function time->value. Then evaluates body.

TimeValueProtocol

protocol

members

time->value

(time->value this)
Return numeric value for given object.

value->time

(value->time this)
Returns Date for given value.

unknown-holiday

(unknown-holiday _)

utc-date

utc-date-value

(utc-date-value)(utc-date-value year)(utc-date-value year month)(utc-date-value year month day)(utc-date-value year month day hour)(utc-date-value year month day hour minute)(utc-date-value year month day hour minute second)(utc-date-value year month day' hour' minute' second' millisecond')
Computes value for given arguments depending with respect to *calendar* binding

value->date

(value->date value)
Returns Date instance for value in seconds for current. Function first
transforms value to local *timezone* value.

value->utc-date

(value->utc-date value)
Casts value to UTC value of Date object

week

604800000

week-in-year?

(week-in-year? value)
Returns which week in year does input value belongs to. For example
for date 15.02.2015 it will return number 6

weekend?

(weekend? value)
Returns true if value in seconds belongs to *weekend-days*

weeks

(weeks n)
Function returns value of n weeks as number.

with-time-configuration

macro

(with-time-configuration {:keys [timezone holiday? offset calendar weekend-days], :or {weekend-days vura.core/*weekend-days*, timezone (vura.core/system-timezone), holiday? *holiday?*, calendar :gregorian, offset nil}} & body)
Utility macro to put context frame on computation scope. Specify:

:holiday?     - (fn [day-context] true | false)
:timezone     - timezone-name
:weekend-days - (fn [number] true | false)
:calendar     - :gregorian, :julian, :islamic, :hebrew

year?

(year? value)
For given value year? returns year that value belogs to.