+csv dep for PG'OCaml.
[cocanwiki.git] / scripts / lib / cocanwiki_date.ml
index ac63b2e..245b3d0 100644 (file)
@@ -1,7 +1,7 @@
 (* COCANWIKI - a wiki written in Objective CAML.
  * Written by Richard W.M. Jones <rich@merjis.com>.
  * Copyright (C) 2004 Merjis Ltd.
- * $Id: cocanwiki_date.ml,v 1.1 2004/10/21 11:42:05 rich Exp $
+ * $Id: cocanwiki_date.ml,v 1.4 2006/03/27 16:43:44 rich Exp $
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -24,29 +24,12 @@ open Registry
 open Cgi
 open Printf
 
-let short_weekday = function
-  | 0 -> "Sun" | 1 -> "Mon" | 2 -> "Tue" | 3 -> "Wed"
-  | 4 -> "Thu" | 5 -> "Fri" | 6 -> "Sat" | 7 -> "Sun"
-  | _ -> invalid_arg "short_weekday"
-
-let short_month = function
-  | 1 -> "Jan" | 2 -> "Feb" | 3 -> "Mar" | 4 -> "Apr"
-  | 5 -> "May" | 6 -> "Jun" | 7 -> "Jul" | 8 -> "Aug"
-  | 9 -> "Sep" | 10 -> "Oct" | 11 -> "Nov" | 12 -> "Dec"
-  | _ -> invalid_arg "short_month"
-
-let long_month = function
-  | 1 -> "January" | 2 -> "February" | 3 -> "March" | 4 -> "April"
-  | 5 -> "May" | 6 -> "June" | 7 -> "July" | 8 -> "August"
-  | 9 -> "September" | 10 -> "October" | 11 -> "November" | 12 -> "December"
-  | _ -> invalid_arg "short_month"
-
 (* Generate a printable datestamp for pages. *)
-let printable_date' date =
-  sprintf "%d %s %04d" date.Dbi.day (short_month date.Dbi.month) date.Dbi.year
+let printable_date' = Printer.DatePrinter.sprint "%d %b %Y"
+
+let printable_date = Printer.CalendarPrinter.sprint "%d %b %Y"
 
-let printable_date (date, _) = printable_date' date
+let printable_date_time = Printer.CalendarPrinter.sprint "%d %b %Y %H:%M"
 
-let printable_date_time (date, time) =
-  sprintf "%d %s %04d %02d:%02d" date.Dbi.day (short_month date.Dbi.month)
-    date.Dbi.year time.Dbi.hour time.Dbi.min
+(* ISO 8601 timestamp. *)
+let iso_8601_date_time = Printer.CalendarPrinter.sprint "%iT%TZ"