Mercurial Hosting > luan
changeset 2174:702075b1f9de default tip
add time zone fns
| author | Franklin Schmidt <fschmidt@gmail.com> |
|---|---|
| date | Mon, 20 Apr 2026 12:13:04 -0600 |
| parents | c3fdf0637eb2 |
| children | |
| files | src/luan/modules/Time.luan |
| diffstat | 1 files changed, 10 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/luan/modules/Time.luan Thu Apr 16 20:28:35 2026 -0600 +++ b/src/luan/modules/Time.luan Mon Apr 20 12:13:04 2026 -0600 @@ -72,7 +72,7 @@ function Time.period( t ) local cal = Calendar.getInstance() - cal.setTimeZone(TimeZone.getTimeZone("GMT")) + cal.setTimeZone(TimeZone.getTimeZone("UTC")) local days = t.days or 0 days = days + 1 cal.set( 1970, 0, days, t.hours or 0, t.minutes or 0, t.seconds or 0 ) @@ -86,6 +86,15 @@ return fmt.parse(source).getTime() end +function Time.get_time_zone_name() + return TimeZone.getDefault().getDisplayName() +end + +function Time.get_time_zone_offset(date) + date = date or System.currentTimeMillis() + return TimeZone.getDefault().getOffset(date) +end + local count_times = { days = Time.period{days=1}
