# HG changeset patch # User Patrick Hurst # Date 1386261406 18000 # Node ID 56c68443cb9d3996a0dd6698032877f599d2c522 # Parent 1e360ea06a099fd6e3fc14e370b67f468f4931f4 Basic datetime library. diff -r 1e360ea06a09 -r 56c68443cb9d Makefile.am --- a/Makefile.am Thu Dec 05 11:36:06 2013 -0500 +++ b/Makefile.am Thu Dec 05 11:36:46 2013 -0500 @@ -95,13 +95,12 @@ endif uninstall-local-main: - rm -f $(DESTDIR)$(BIN)/urweb \ - $(DESTDIR)$(LIB_UR)/basis.urs $(DESTDIR)$(LIB_UR)/char.urs $(DESTDIR)$(LIB_UR)/listPair.urs $(DESTDIR)$(LIB_UR)/list.urs \ - $(DESTDIR)$(LIB_UR)/monad.urs $(DESTDIR)$(LIB_UR)/option.urs $(DESTDIR)$(LIB_UR)/string.urs $(DESTDIR)$(LIB_UR)/top.urs \ - $(DESTDIR)$(LIB_UR)/char.ur $(DESTDIR)$(LIB_UR)/listPair.ur $(DESTDIR)$(LIB_UR)/list.ur \ - $(DESTDIR)$(LIB_UR)/monad.ur $(DESTDIR)$(LIB_UR)/option.ur $(DESTDIR)$(LIB_UR)/string.ur $(DESTDIR)$(LIB_UR)/top.ur \ - $(DESTDIR)$(LIB_JS)/urweb.js \ - $(DESTDIR)$(INCLUDE)/config.h $(DESTDIR)$(INCLUDE)/queue.h $(DESTDIR)$(INCLUDE)/request.h $(DESTDIR)$(INCLUDE)/types.h \ + rm -f $(DESTDIR)$(BIN)/urweb $(DESTDIR)$(LIB_UR)/basis.urs $(DESTDIR)$(LIB_UR)/char.urs $(DESTDIR)$(LIB_UR)/datetime.urs \ + $(DESTDIR)$(LIB_UR)/listPair.urs \ $(DESTDIR)$(LIB_UR)/list.urs $(DESTDIR)$(LIB_UR)/monad.urs \ + $(DESTDIR)$(LIB_UR)/option.urs $(DESTDIR)$(LIB_UR)/string.urs $(DESTDIR)$(LIB_UR)/top.urs $(DESTDIR)$(LIB_UR)/char.ur \ + $(DESTDIR)$(LIB_UR)/datetime.ur $(DESTDIR)$(LIB_UR)/listPair.ur $(DESTDIR)$(LIB_UR)/list.ur $(DESTDIR)$(LIB_UR)/monad.ur \ + $(DESTDIR)$(LIB_UR)/option.ur $(DESTDIR)$(LIB_UR)/string.ur $(DESTDIR)$(LIB_UR)/top.ur $(DESTDIR)$(LIB_JS)/urweb.js \ + $(DESTDIR)$(INCLUDE)/config.h $(DESTDIR)$(INCLUDE)/queue.h $(DESTDIR)$(INCLUDE)/request.h $(DESTDIR)$(INCLUDE)/types.h \ $(DESTDIR)$(INCLUDE)/urweb.h $(DESTDIR)$(INCLUDE)/types_cpp.h $(DESTDIR)$(INCLUDE)/urweb_cpp.h uninstall-local: uninstall-local-main uninstall-emacs diff -r 1e360ea06a09 -r 56c68443cb9d lib/ur/datetime.ur --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/ur/datetime.ur Thu Dec 05 11:36:46 2013 -0500 @@ -0,0 +1,26 @@ +type datetime = { + Year : int, + Month : int, + Day : int, + Hour : int, + Minute : int, + Second : int +} + +fun toTime dt : time = fromDatetime dt.Year dt.Month dt.Day + dt.Hour dt.Minute dt.Second + +fun fromTime t : datetime = { + Year = datetimeYear t, + Month = datetimeMonth t, + Day = datetimeDay t, + Hour = datetimeHour t, + Minute = datetimeMinute t, + Second = datetimeSecond t +} + +fun datetimef fmt dt : string = timef fmt (toTime dt) + +val now : transaction datetime = + n <- now; + return (fromTime n) diff -r 1e360ea06a09 -r 56c68443cb9d lib/ur/datetime.urs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/ur/datetime.urs Thu Dec 05 11:36:46 2013 -0500 @@ -0,0 +1,12 @@ +type datetime = { Year : int, + Month : int, + Day : int, + Hour : int, + Minute : int, + Second : int + } + +val toTime : datetime -> time +val fromTime : time -> datetime +val datetimef : string -> datetime -> string +val now : transaction datetime