X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;ds=sidebyside;f=scripts%2Flib%2Fcocanwiki_date.ml;h=245b3d091c87acbfea398af9cd6fb8035b943612;hb=d303f75eed3a09bbe2516d9a2a9a4aa9b862ceb3;hp=124f3f7d28b50ce1418c3726eb51907e7ba7b747;hpb=fb1c781bdbe4a2b296651a051dda11d210c9ad33;p=cocanwiki.git diff --git a/scripts/lib/cocanwiki_date.ml b/scripts/lib/cocanwiki_date.ml index 124f3f7..245b3d0 100644 --- a/scripts/lib/cocanwiki_date.ml +++ b/scripts/lib/cocanwiki_date.ml @@ -1,7 +1,7 @@ (* COCANWIKI - a wiki written in Objective CAML. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: cocanwiki_date.ml,v 1.3 2005/11/23 11:32:38 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,38 +24,12 @@ open Registry open Cgi open Printf -let short_weekday = function - | Date.Sun -> "Sun" | Date.Mon -> "Mon" | Date.Tue -> "Tue" - | Date.Wed -> "Wed" | Date.Thu -> "Thu" | Date.Fri -> "Fri" - | Date.Sat -> "Sat" - -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 (date, _) = printable_date' date +let printable_date = Printer.CalendarPrinter.sprint "%d %b %Y" -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 +let printable_date_time = Printer.CalendarPrinter.sprint "%d %b %Y %H:%M" (* ISO 8601 timestamp. *) -let iso_8601_date_time (date, time) = - sprintf "%04d-%02d-%02dT%02d:%02d:%02d" - date.Dbi.year date.Dbi.month date.Dbi.day - time.Dbi.hour time.Dbi.min time.Dbi.sec ^ - match time.Dbi.timezone with - | None -> "Z" - | Some t -> sprintf "+%02d:00" t +let iso_8601_date_time = Printer.CalendarPrinter.sprint "%iT%TZ"