Mercurial Hosting > luan
changeset 256:15122d724ce4
more Time functions
git-svn-id: https://luan-java.googlecode.com/svn/trunk@257 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Tue, 28 Oct 2014 01:59:35 +0000 |
parents | e5ad26746c94 |
children | c5c60eca33dd |
files | 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 | 6 files changed, 13 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/core/src/luan/modules/Time.luan Mon Oct 27 21:19:42 2014 +0000 +++ b/core/src/luan/modules/Time.luan Tue Oct 28 01:59:35 2014 +0000 @@ -39,3 +39,16 @@ function format(time,pattern) return SimpleDateFormat.new(pattern).format(Date.new(time)) end + +function on( year, month, day, hour, minute, second, millis ) + month = month - 1 + local cal = Calendar.getInstance() + 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 parse( pattern, source ) + return SimpleDateFormat.new(pattern).parse(source).getTime() +end + \ No newline at end of file