diff core/src/luan/modules/Time.luan @ 503:92c3d22745b8

make _ENV optional
author Franklin Schmidt <fschmidt@gmail.com>
date Wed, 20 May 2015 23:24:46 -0600
parents 7f7708e8fdd4
children fa281ee942c8
line wrap: on
line diff
--- a/core/src/luan/modules/Time.luan	Tue May 19 17:57:20 2015 -0600
+++ b/core/src/luan/modules/Time.luan	Wed May 20 23:24:46 2015 -0600
@@ -1,7 +1,9 @@
 -- incomplete, will add as needed
 
 java()
-require "luan:String"
+local Luan = require "luan:Luan"
+local ipairs = Luan.ipairs
+local error = Luan.error
 local Table = require "luan:Table"
 local System = require "java:java.lang.System"
 local Calendar = require "java:java.util.Calendar"
@@ -9,8 +11,9 @@
 local TimeZone = require "java:java.util.TimeZone"
 local SimpleDateFormat = require "java:java.text.SimpleDateFormat"
 
+local M = {}
 
-function now()
+function M.now()
 	return System.currentTimeMillis()
 end
 
@@ -21,7 +24,7 @@
 	day_of_month = Calendar.DAY_OF_MONTH;
 }
 
-function get( time, ... )
+function M.get( time, ... )
 	local cal = Calendar.getInstance()
 	cal.setTimeInMillis(time)
 	local rtn = {}
@@ -37,12 +40,12 @@
 	return Table.unpack(rtn)
 end
 
-function format(time,pattern)
+function M.format(time,pattern)
 	pattern = pattern or "yyyy-MM-dd HH:m:ss"
 	return SimpleDateFormat.new(pattern).format(Date.new(time))
 end
 
-function on( year, month, day, hour, minute, second, millis )
+function M.on( year, month, day, hour, minute, second, millis )
 	month = month - 1
 	local cal = Calendar.getInstance()
 	cal.setLenient(false)
@@ -51,7 +54,7 @@
 	return cal.getTimeInMillis()
 end
 
-function period( days, hours, minutes, seconds, millis )
+function M.period( days, hours, minutes, seconds, millis )
 	local cal = Calendar.getInstance()
 	cal.setTimeZone(TimeZone.getTimeZone("GMT"))
 	days = days + 1
@@ -60,6 +63,8 @@
 	return cal.getTimeInMillis()
 end
 
-function parse( pattern, source )
+function M.parse( pattern, source )
 	return SimpleDateFormat.new(pattern).parse(source).getTime()
 end
+
+return M