Something went wrong. Try again.
My own corner of monopam
Something went wrong. Try again.
2.0 kB · 34 lines
OCaml
at main
1234567891011121314151617181920212223242526272829303132333435(*--------------------------------------------------------------------------- Copyright (c) 2025 Thomas Gazagnaire. All rights reserved. SPDX-License-Identifier: ISC ---------------------------------------------------------------------------*)
(** SQLite date and time functions (lang_datefunc.html).
Time is a Julian day number in integer milliseconds, as in sqlite3, so every result that depends only on the arguments is exact: time strings, Julian and unix numbers, and the unit, start-of, weekday, auto, unixepoch and subsec modifiers. What depends on the machine, the current instant and the local time offset, is an argument of {!call}. *)
val call : ?now:int64 -> ?zone:(int64 -> int) -> string -> Ast.value list -> Ast.value(** [call ~now ~zone name args] is the date and time function [name], one of ["date"], ["time"], ["datetime"], ["julianday"], ["unixepoch"] and ["strftime"], applied to [args]. The first argument, after the format of [strftime], is the time value and the others are modifiers. As in sqlite3, a malformed value, a field out of range or an unknown modifier gives [Null].
[now] is the instant ['now'] reads, in milliseconds since the unix epoch. Without it, ['now'] and the [CURRENT_*] keywords are [Null]. [zone t] is the local time offset in seconds east of UTC at the instant [t], in milliseconds since the unix epoch; ['localtime'] adds it and ['utc'] subtracts it. It defaults to UTC, as the sqlite3 CLI under [TZ=UTC].
@raise Invalid_argument if [name] is not a date/time function. *)
val reads_the_clock : string -> Ast.value list -> bool(** [reads_the_clock name args] is [true] iff the call reads the clock or the time zone of the machine: it has no time value, or a value or modifier that is ['now'], ['subsec'], ['subsecond'], ['localtime'] or ['utc'], compared without case over the whole string, as sqlite3 does (src/date.c). *)