From dbddbd9b0cec1bfe8e92a39552b28ab2f11195d9 Mon Sep 17 00:00:00 2001 From: Mike Mason Date: Wed, 28 Nov 2007 15:26:13 +0000 Subject: added split and join to fs.lua and gave them function names so we don't have to strsplit = require split. Added a date string to table function in date.lua git-svn-id: svn://svn.alpinelinux.org/acf/core/trunk@378 ab2d0c66-481e-0410-8bed-d214d4d58bed --- lib/date.lua | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'lib/date.lua') diff --git a/lib/date.lua b/lib/date.lua index a7ed872..0a236cc 100644 --- a/lib/date.lua +++ b/lib/date.lua @@ -3,6 +3,7 @@ module(..., package.seeall) require("posix") +require("fs") --global for date formating see below for more information --Mon Nov 26 19:56:10 UTC 2007 looks like most systems use this @@ -89,6 +90,33 @@ function seconds_to_date (t) return g end +--Wed Nov 28 14:01:23 UTC 2007 +--os.date(date.format) put into a table +--year,month,day,hour,min,sec,isdst- may need a dst table to set this automatically +function string_to_table (str) + if str == nil then str = os.date(format) end + g = {} + temp = fs.string_to_table("%s",str) + month = abr_month_num(temp[2]) + g["month"] = month + day = temp[3] + g["day"] = day + --may do something with this if have a tz table ?? + tz = temp[5] + year = temp[6] + g["year"] = year + temp2 = fs.string_to_table(":",temp[4]) + hour = temp2[1] + g["hour"] = hour + min = temp2[2] + g["min"] = min + sec = temp2[3] + g["sec"] = sec + return g + +end + + --give dates in seconds and gives the difference in years,months,days,... --gives a table back with hour,min,month,sec,day,year to display something like --you have 10 years, 14 hours, 10 days to renew you certificate -- cgit v1.2.3