Archetype.DatetimeSourceDescribes a date associated with a time. The "default" date format is yyyy-mm-dd HH:mm-ss. In addition to describing data as injectable or readable, the module provides a naive date processing API that seems to be useful for describing a blog.
Types used to describe a date.
Type describing a month
Type describing a year (positive int, Because let's face it, we're not going to publish blogs during antiquity, are we?).
Type describing a day. A number from 1 to 31 (depending on the month).
Type describing an hour. A number from 0 to 23.
Type describing a minut. A number from 0 to 59.
Type describing a second. A number from 0 to 59.
Describes a complete date. As all potentially different values are private, the type must not be abstract (or private), as it must go through validation phases.
val make :
?time:(int * int * int) ->
year:int ->
month:int ->
day:int ->
unit ->
t Data.Validation.validated_valuemake ?time ~year ~month ~day () Builds a date when all data and validates all data.
include Data.Validation.S with type t := ttype data := Data.tLocal alias for Yocaml.Data.t.
from_data data converts a Yocaml.Data.t into an OCaml value of type t. Returns Ok v on success or Error e on failure.
validate data try to read a date from a generic representation.
include Data.S with type t := ttype data := Data.tLocal alias for Yocaml.Data.t.
to_data v converts an OCaml value v of type t into a Yocaml.Data.t.
normalize datetime render data generically (with additional fields). Here is the list of fields:
year: int the year valuemonth: int the month valueday: int the day valuehour: int the hour valuemin: int the min valuesec: int the sec valuehas_time: bool true if time is different than 0,0,0, false otherwiseday_of_week: int a number that represent the day of week (0: Monday, 6: Sunday)repr: record some representation of the dateRepresentation of a date (field repr) :
repr.month: string a three-letters ident for the monthrepr.day_of_week: string a three-letters ident for the day of the weekrepr.datetime: string a string representation of the date YYYY-mm-dd HH:mm:ssrepr.date: string a string representation of the date YYYY-mm-ddrepr.time: string a string representation of the date HH:mm:ssGenerating so much data may seem strange, but it allows the user to decide precisely, in his template, how to use/represent a date, which, in my opinion, is a good thing. No ?
Pretty printer for date.
Pretty printer according to the RFC822 specification.
Pretty printer according to the RFC822 specification.