Menu

#45 os.date("*t") hour field should be "0-23" not "0-11"

v3.0.1
closed-fixed
nobody
None
5
2015-05-01
2015-03-17
No

hour field returned by os.date("*t") takes value from 0 to 11 but it should be 0-23.
Here is the patch for luaj 3.0.

--- src/core/org/luaj/vm2/lib/OsLib.java.org    2015-03-17 20:35:52.000000000 +0900
+++ src/core/org/luaj/vm2/lib/OsLib.java    2015-03-17 20:36:16.000000000 +0900
@@ -150,7 +150,7 @@
                        tbl.set("year", LuaValue.valueOf(d.get(Calendar.YEAR)));
                        tbl.set("month", LuaValue.valueOf(d.get(Calendar.MONTH)+1));
                        tbl.set("day", LuaValue.valueOf(d.get(Calendar.DAY_OF_MONTH)));
-                       tbl.set("hour", LuaValue.valueOf(d.get(Calendar.HOUR)));
+                       tbl.set("hour", LuaValue.valueOf(d.get(Calendar.HOUR_OF_DAY)));
                        tbl.set("min", LuaValue.valueOf(d.get(Calendar.MINUTE)));
                        tbl.set("sec", LuaValue.valueOf(d.get(Calendar.SECOND)));
                        tbl.set("wday", LuaValue.valueOf(d.get(Calendar.DAY_OF_WEEK)));

Discussion

  • James Roseborough

    • status: open --> pending-fixed
     
  • James Roseborough

    Will be fixed in version 3.0.1

     
  • James Roseborough

    Is fixed in version 3.0.1.

     
  • James Roseborough

    • status: pending-fixed --> closed-fixed
     

Log in to post a comment.