Mercurial Hosting > luan
comparison src/luan/modules/Time.luan @ 1084:aa967fd73b80
improve error message
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sat, 26 Nov 2016 20:51:14 -0700 |
parents | 53e77f60b789 |
children | bae2d0c2576c |
comparison
equal
deleted
inserted
replaced
1083:e7fb974e0c26 | 1084:aa967fd73b80 |
---|---|
1 -- incomplete, will add as needed | 1 -- incomplete, will add as needed |
2 | 2 |
3 java() | 3 java() |
4 local Luan = require "luan:Luan.luan" | 4 local Luan = require "luan:Luan.luan" |
5 local error = Luan.error | 5 local error = Luan.error |
6 local assert_long = Luan.assert_long or error() | |
6 local ipairs = Luan.ipairs or error() | 7 local ipairs = Luan.ipairs or error() |
7 local Math = require "luan:Math.luan" | 8 local Math = require "luan:Math.luan" |
8 local floor = Math.floor or error() | 9 local floor = Math.floor or error() |
9 local Table = require "luan:Table.luan" | 10 local Table = require "luan:Table.luan" |
10 local System = require "java:java.lang.System" | 11 local System = require "java:java.lang.System" |
41 end | 42 end |
42 return Table.unpack(rtn) | 43 return Table.unpack(rtn) |
43 end | 44 end |
44 | 45 |
45 function M.format(time,pattern) | 46 function M.format(time,pattern) |
47 time = assert_long(time) | |
46 pattern = pattern or "yyyy-MM-dd HH:mm:ss" | 48 pattern = pattern or "yyyy-MM-dd HH:mm:ss" |
47 return SimpleDateFormat.new(pattern).format(Date.new(time)) | 49 return SimpleDateFormat.new(pattern).format(Date.new(time)) |
48 end | 50 end |
49 | 51 |
50 function M.on( year, month, day, hour, minute, second, millis ) | 52 function M.on( year, month, day, hour, minute, second, millis ) |