changeset 290:9a0cc6d9b27b

add Time.period(); add assert_long(); git-svn-id: https://luan-java.googlecode.com/svn/trunk@291 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Tue, 09 Dec 2014 04:39:18 +0000
parents ae7ae2755b48
children a35d1177bbf0
files core/src/luan/init.luan core/src/luan/modules/BasicLuan.java core/src/luan/modules/Time.luan dist/jars/luan-core-trunk.jar dist/jars/luan-logging-trunk.jar dist/jars/luan-lucene-trunk.jar dist/jars/luan-mail-trunk.jar dist/jars/luan-web-trunk.jar
diffstat 8 files changed, 17 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/core/src/luan/init.luan	Mon Dec 08 07:45:40 2014 +0000
+++ b/core/src/luan/init.luan	Tue Dec 09 04:39:18 2014 +0000
@@ -19,6 +19,7 @@
 Package.global(Basic,"assert_string")
 Package.global(Basic,"assert_table")
 Package.global(Basic,"assert_integer")
+Package.global(Basic,"assert_long")
 local do_file = Package.global(Basic,"do_file")
 Package.global(Basic,"error")
 Package.global(Basic,"get_metatable")
--- a/core/src/luan/modules/BasicLuan.java	Mon Dec 08 07:45:40 2014 +0000
+++ b/core/src/luan/modules/BasicLuan.java	Tue Dec 09 04:39:18 2014 +0000
@@ -31,6 +31,7 @@
 				add( module, "assert_string", LuanState.class, String.class );
 				add( module, "assert_table", LuanState.class, LuanTable.class );
 				add( module, "assert_integer", LuanState.class, Integer.TYPE );
+				add( module, "assert_long", LuanState.class, Long.TYPE );
 				add( module, "do_file", LuanState.class, String.class );
 				add( module, "error", LuanState.class, Object.class );
 				add( module, "get_metatable", LuanState.class, Object.class );
@@ -204,6 +205,10 @@
 		return v;
 	}
 
+	public static long assert_long(LuanState luan,long v) throws LuanException {
+		return v;
+	}
+
 	public static String repr(LuanState luan,Object v) throws LuanException {
 		return luan.repr(v);
 	}
--- a/core/src/luan/modules/Time.luan	Mon Dec 08 07:45:40 2014 +0000
+++ b/core/src/luan/modules/Time.luan	Tue Dec 09 04:39:18 2014 +0000
@@ -6,6 +6,7 @@
 import "java:java.lang.System"
 import "java:java.util.Calendar"
 import "java:java.util.Date"
+import "java:java.util.TimeZone"
 import "java:java.text.SimpleDateFormat"
 
 
@@ -44,11 +45,21 @@
 function on( year, month, day, hour, minute, second, millis )
 	month = month - 1
 	local cal = Calendar.getInstance()
+	cal.setLenient(false)
 	cal.set( year, month, day, hour or 0, minute or 0, second or 0 )
 	cal.set( Calendar.MILLISECOND, millis or 0 )
 	return cal.getTimeInMillis()
 end
 
+function period( days, hours, minutes, seconds, millis )
+	local cal = Calendar.getInstance()
+	cal.setTimeZone(TimeZone.getTimeZone("GMT"))
+	days = days + 1
+	cal.set( 1970, 0, days, hours or 0, minutes or 0, seconds or 0 )
+	cal.set( Calendar.MILLISECOND, millis or 0 )
+	return cal.getTimeInMillis()
+end
+
 function parse( pattern, source )
 	return SimpleDateFormat.new(pattern).parse(source).getTime()
 end
Binary file dist/jars/luan-core-trunk.jar has changed
Binary file dist/jars/luan-logging-trunk.jar has changed
Binary file dist/jars/luan-lucene-trunk.jar has changed
Binary file dist/jars/luan-mail-trunk.jar has changed
Binary file dist/jars/luan-web-trunk.jar has changed