Timedelta

this is a complementary module to be used with Datetime and is concerned with adding and subtracting time values of the scale from seconds to weeks from Datetime values.

Example:

(load "git@github.com:carpentry-org/time.carp@0.1.0")

(defn main []
  (println*
    &(Datetime.strftime
      &(Timedelta.sub &(Datetime.now) &(Timedelta.days 2))
      "%Y-%m-%d %I:%M:%S.%n %p %z")))

add

defn

(Fn [(Ref Datetime a), (Ref Timedelta b)] Datetime)

                        (add dt delta)
                    

adds a Timedelta delta to a Datetime dt.

copy

instantiate

(Fn [(Ref Timedelta a)] Timedelta)

copies a Timedelta.

days

defn

(Fn [Int] Timedelta)

                        (days n)
                    

creates a delta representing a number of days n.

delete

instantiate

(Fn [Timedelta] ())

deletes a Timedelta. Should usually not be called manually.

hours

defn

(Fn [Int] Timedelta)

                        (hours n)
                    

creates a delta representing a number of hours n.

minutes

defn

(Fn [Int] Timedelta)

                        (minutes n)
                    

creates a delta representing a number of minutes n.

prn

instantiate

(Fn [(Ref Timedelta a)] String)

converts a Timedelta to a string.

seconds

defn

(Fn [Int] Timedelta)

                        (seconds n)
                    

creates a delta representing a number of seconds n.

str

instantiate

(Fn [(Ref Timedelta a)] String)

converts a Timedelta to a string.

sub

defn

(Fn [(Ref Datetime a), (Ref Timedelta b)] Datetime)

                        (sub dt delta)
                    

subtracts a Timedelta delta from a Datetime dt.

weeks

defn

(Fn [Int] Timedelta)

                        (weeks n)
                    

creates a delta representing a number of weeks n.