package granary

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Granary_sql.DatetimeSource

Pure-OCaml date/time module for SQL date/time functions.

Sourcetype dt = {
  1. year : int;
  2. month : int;
  3. day : int;
  4. hour : int;
  5. min : int;
  6. sec : float;
}
Sourceval parse : ?now:(unit -> float) -> string -> (dt, string) result

Parse a time string. Accepted formats:

  • 'YYYY-MM-DD' — date only, time = 00:00:00
  • 'YYYY-MM-DD HH:MM:SS' — date and time (space or T separator)
  • 'HH:MM[:SS]' — time only, date = 2000-01-01
  • 'now' — requires ~now clock; returns current UTC time
  • integer/float — unix epoch or Julian day number
Sourceval to_date : dt -> string

"YYYY-MM-DD"

Sourceval to_time : dt -> string

"HH:MM:SS"

Sourceval to_datetime : dt -> string

"YYYY-MM-DD HH:MM:SS"

Sourceval to_julianday : dt -> float

Julian day number.

Sourceval to_unixepoch : dt -> int64

Seconds since the Unix epoch.

Sourceval strftime : string -> dt -> string

strftime fmt dt formats dt using fmt. Supported: %Y %m %d %H %M %S %f %j %s %%