summaryrefslogtreecommitdiffstats
path: root/lib/date.lua
diff options
context:
space:
mode:
authorMike Mason <ms13sp@gmail.com>2007-11-23 22:38:25 +0000
committerMike Mason <ms13sp@gmail.com>2007-11-23 22:38:25 +0000
commitc81b1c6057a070d7668f81f32d4182e56e753df1 (patch)
tree46147cf41dcf7eac5a2c49bcce6c06d16a23da8a /lib/date.lua
parentbf5d83c373f610aea01220b74b77590bdf0a473f (diff)
downloadacf-core-c81b1c6057a070d7668f81f32d4182e56e753df1.tar.bz2
acf-core-c81b1c6057a070d7668f81f32d4182e56e753df1.tar.xz
Adding date and time functionality
git-svn-id: svn://svn.alpinelinux.org/acf/core/trunk@364 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'lib/date.lua')
-rw-r--r--lib/date.lua55
1 files changed, 55 insertions, 0 deletions
diff --git a/lib/date.lua b/lib/date.lua
new file mode 100644
index 0000000..d588ecc
--- /dev/null
+++ b/lib/date.lua
@@ -0,0 +1,55 @@
+--date and time functions
+
+
+module(..., package.seeall)
+
+require("posix")
+
+months ={ {"January","Jan"},
+ {"February", "Feb"},
+ {"March","Mar"},
+ {"April", "Apr"},
+ {"May","May"},
+ {"June","Jun"},
+ {"July","Jul"},
+ {"August","Aug"},
+ {"September","Sep"},
+ {"October","Oct"},
+ {"November","Nov"},
+ {"December","Dec"}
+ }
+-- i am sure there is a better way to do this than a new table
+
+revmonths = {["January"] = 1, ["Jan"] = 1,
+ ["February"] = 2, ["Feb"] = 2,
+ ["March"] = 3, ["Mar"] = 3,
+ ["April"] = 4, ["Apr"] = 4,
+ ["May"] = 5,
+ ["June"] = 6, ["Jun"] = 6,
+ ["July"] = 7, ["Jul"] = 7,
+ ["August"] = 8, ["Aug"] = 8,
+ ["September"] = 9, ["Sep"] = 9,
+ ["October"] = 10, ["Oct"] = 10,
+ ["November"] = 11, ["Nov"] = 11,
+ ["December"] = 12, ["Dec"] = 12
+ }
+
+--give a search number and return the month name
+
+function num_month_name (search)
+ return months[search][1]
+end
+
+--give a search number and return the month abr
+
+function num_month_name_abr (search)
+ return months[search][2]
+end
+
+function name_month_num (search)
+ return revmonths[search]
+end
+
+function abr_month_num (search)
+ return revmonths[search]
+end