rufus-lua-win 5.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (459) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +69 -0
  6. data/Rakefile +1 -0
  7. data/lib/rufus/lua/win.rb +18 -0
  8. data/lib/rufus/lua/win/version.rb +7 -0
  9. data/rufus-lua-win.gemspec +23 -0
  10. data/vendor/lua/bin/liblua.dll +0 -0
  11. data/vendor/lua/lib/lua/LuaXml.lua +119 -0
  12. data/vendor/lua/lib/lua/alien.lua +250 -0
  13. data/vendor/lua/lib/lua/alien/core.dll +0 -0
  14. data/vendor/lua/lib/lua/alien/struct.dll +0 -0
  15. data/vendor/lua/lib/lua/base.lua +536 -0
  16. data/vendor/lua/lib/lua/bin.lua +20 -0
  17. data/vendor/lua/lib/lua/bit.dll +0 -0
  18. data/vendor/lua/lib/lua/cdlua.dll +0 -0
  19. data/vendor/lua/lib/lua/cdluacontextplus.dll +0 -0
  20. data/vendor/lua/lib/lua/cdluagl.dll +0 -0
  21. data/vendor/lua/lib/lua/cdluaim.dll +0 -0
  22. data/vendor/lua/lib/lua/cdluapdf.dll +0 -0
  23. data/vendor/lua/lib/lua/copas.lua +543 -0
  24. data/vendor/lua/lib/lua/coxpcall.lua +57 -0
  25. data/vendor/lua/lib/lua/date.lua +745 -0
  26. data/vendor/lua/lib/lua/debug_ext.lua +84 -0
  27. data/vendor/lua/lib/lua/debug_init.lua +2 -0
  28. data/vendor/lua/lib/lua/des56.dll +0 -0
  29. data/vendor/lua/lib/lua/dist/config.lua +109 -0
  30. data/vendor/lua/lib/lua/dist/constraints.lua +271 -0
  31. data/vendor/lua/lib/lua/dist/depends.lua +601 -0
  32. data/vendor/lua/lib/lua/dist/git.lua +307 -0
  33. data/vendor/lua/lib/lua/dist/init.lua +278 -0
  34. data/vendor/lua/lib/lua/dist/manifest.lua +225 -0
  35. data/vendor/lua/lib/lua/dist/package.lua +583 -0
  36. data/vendor/lua/lib/lua/dist/sys.lua +367 -0
  37. data/vendor/lua/lib/lua/dist/utils.lua +130 -0
  38. data/vendor/lua/lib/lua/ex.dll +0 -0
  39. data/vendor/lua/lib/lua/fstable.lua +116 -0
  40. data/vendor/lua/lib/lua/getopt.lua +273 -0
  41. data/vendor/lua/lib/lua/git.lua +5 -0
  42. data/vendor/lua/lib/lua/git/core.dll +0 -0
  43. data/vendor/lua/lib/lua/git/objects.lua +121 -0
  44. data/vendor/lua/lib/lua/git/pack.lua +316 -0
  45. data/vendor/lua/lib/lua/git/protocol.lua +188 -0
  46. data/vendor/lua/lib/lua/git/repo.lua +283 -0
  47. data/vendor/lua/lib/lua/git/util.lua +233 -0
  48. data/vendor/lua/lib/lua/gzio.dll +0 -0
  49. data/vendor/lua/lib/lua/gzip.lua +81 -0
  50. data/vendor/lua/lib/lua/iconv.dll +0 -0
  51. data/vendor/lua/lib/lua/imlua.dll +0 -0
  52. data/vendor/lua/lib/lua/imlua_fftw.dll +0 -0
  53. data/vendor/lua/lib/lua/imlua_jp2.dll +0 -0
  54. data/vendor/lua/lib/lua/imlua_process.dll +0 -0
  55. data/vendor/lua/lib/lua/imlua_process_omp.dll +0 -0
  56. data/vendor/lua/lib/lua/io_ext.lua +115 -0
  57. data/vendor/lua/lib/lua/iuplua.dll +0 -0
  58. data/vendor/lua/lib/lua/iuplua_mglplot.dll +0 -0
  59. data/vendor/lua/lib/lua/iuplua_pplot.dll +0 -0
  60. data/vendor/lua/lib/lua/iupluacd.dll +0 -0
  61. data/vendor/lua/lib/lua/iupluacontrols.dll +0 -0
  62. data/vendor/lua/lib/lua/iupluagl.dll +0 -0
  63. data/vendor/lua/lib/lua/iupluaim.dll +0 -0
  64. data/vendor/lua/lib/lua/iupluaimglib.dll +0 -0
  65. data/vendor/lua/lib/lua/iupluatuio.dll +0 -0
  66. data/vendor/lua/lib/lua/lanes-keeper.lua +302 -0
  67. data/vendor/lua/lib/lua/lanes.lua +591 -0
  68. data/vendor/lua/lib/lua/lanes/core.dll +0 -0
  69. data/vendor/lua/lib/lua/lcs.lua +55 -0
  70. data/vendor/lua/lib/lua/lemock.lua +659 -0
  71. data/vendor/lua/lib/lua/lfs.dll +0 -0
  72. data/vendor/lua/lib/lua/list.lua +375 -0
  73. data/vendor/lua/lib/lua/logging.lua +189 -0
  74. data/vendor/lua/lib/lua/logging/console.lua +22 -0
  75. data/vendor/lua/lib/lua/logging/email.lua +44 -0
  76. data/vendor/lua/lib/lua/logging/file.lua +55 -0
  77. data/vendor/lua/lib/lua/logging/rolling_file.lua +81 -0
  78. data/vendor/lua/lib/lua/logging/socket.lua +35 -0
  79. data/vendor/lua/lib/lua/logging/sql.lua +64 -0
  80. data/vendor/lua/lib/lua/loop/base.lua +68 -0
  81. data/vendor/lua/lib/lua/loop/cached.lua +312 -0
  82. data/vendor/lua/lib/lua/loop/collection/MapWithArrayOfKeys.lua +64 -0
  83. data/vendor/lua/lib/lua/loop/collection/ObjectCache.lua +39 -0
  84. data/vendor/lua/lib/lua/loop/collection/OrderedSet.lua +164 -0
  85. data/vendor/lua/lib/lua/loop/collection/PriorityQueue.lua +86 -0
  86. data/vendor/lua/lib/lua/loop/collection/UnorderedArray.lua +32 -0
  87. data/vendor/lua/lib/lua/loop/collection/UnorderedArraySet.lua +56 -0
  88. data/vendor/lua/lib/lua/loop/compiler/Arguments.lua +108 -0
  89. data/vendor/lua/lib/lua/loop/compiler/Conditional.lua +50 -0
  90. data/vendor/lua/lib/lua/loop/compiler/Expression.lua +215 -0
  91. data/vendor/lua/lib/lua/loop/component/base.lua +221 -0
  92. data/vendor/lua/lib/lua/loop/component/contained.lua +71 -0
  93. data/vendor/lua/lib/lua/loop/component/dynamic.lua +223 -0
  94. data/vendor/lua/lib/lua/loop/component/intercepted.lua +354 -0
  95. data/vendor/lua/lib/lua/loop/component/wrapped.lua +195 -0
  96. data/vendor/lua/lib/lua/loop/debug/Inspector.lua +521 -0
  97. data/vendor/lua/lib/lua/loop/debug/Matcher.lua +192 -0
  98. data/vendor/lua/lib/lua/loop/debug/Verbose.lua +266 -0
  99. data/vendor/lua/lib/lua/loop/debug/Viewer.lua +200 -0
  100. data/vendor/lua/lib/lua/loop/multiple.lua +105 -0
  101. data/vendor/lua/lib/lua/loop/object/Exception.lua +57 -0
  102. data/vendor/lua/lib/lua/loop/object/Publisher.lua +43 -0
  103. data/vendor/lua/lib/lua/loop/object/Wrapper.lua +39 -0
  104. data/vendor/lua/lib/lua/loop/scoped.lua +585 -0
  105. data/vendor/lua/lib/lua/loop/serial/FileStream.lua +48 -0
  106. data/vendor/lua/lib/lua/loop/serial/Serializer.lua +291 -0
  107. data/vendor/lua/lib/lua/loop/serial/SocketStream.lua +51 -0
  108. data/vendor/lua/lib/lua/loop/serial/StringStream.lua +47 -0
  109. data/vendor/lua/lib/lua/loop/simple.lua +75 -0
  110. data/vendor/lua/lib/lua/loop/table.lua +71 -0
  111. data/vendor/lua/lib/lua/loop/thread/CoSocket.lua +416 -0
  112. data/vendor/lua/lib/lua/loop/thread/IOScheduler.lua +170 -0
  113. data/vendor/lua/lib/lua/loop/thread/Scheduler.lua +327 -0
  114. data/vendor/lua/lib/lua/loop/thread/SocketScheduler.lua +88 -0
  115. data/vendor/lua/lib/lua/loop/thread/Timer.lua +54 -0
  116. data/vendor/lua/lib/lua/lpeg.dll +0 -0
  117. data/vendor/lua/lib/lua/ltn12.lua +292 -0
  118. data/vendor/lua/lib/lua/luaXML_lib.dll +0 -0
  119. data/vendor/lua/lib/lua/luacurl.dll +0 -0
  120. data/vendor/lua/lib/lua/luadoc/config.lua +34 -0
  121. data/vendor/lua/lib/lua/luadoc/doclet/debug.lua +46 -0
  122. data/vendor/lua/lib/lua/luadoc/doclet/formatter.lua +84 -0
  123. data/vendor/lua/lib/lua/luadoc/doclet/html.lua +289 -0
  124. data/vendor/lua/lib/lua/luadoc/doclet/html/file.lp +113 -0
  125. data/vendor/lua/lib/lua/luadoc/doclet/html/function.lp +64 -0
  126. data/vendor/lua/lib/lua/luadoc/doclet/html/index.lp +70 -0
  127. data/vendor/lua/lib/lua/luadoc/doclet/html/luadoc.css +286 -0
  128. data/vendor/lua/lib/lua/luadoc/doclet/html/menu.lp +55 -0
  129. data/vendor/lua/lib/lua/luadoc/doclet/html/module.lp +109 -0
  130. data/vendor/lua/lib/lua/luadoc/doclet/html/table.lp +15 -0
  131. data/vendor/lua/lib/lua/luadoc/doclet/raw.lua +12 -0
  132. data/vendor/lua/lib/lua/luadoc/init.lua +58 -0
  133. data/vendor/lua/lib/lua/luadoc/lp.lua +130 -0
  134. data/vendor/lua/lib/lua/luadoc/taglet/standard.lua +495 -0
  135. data/vendor/lua/lib/lua/luadoc/taglet/standard/tags.lua +171 -0
  136. data/vendor/lua/lib/lua/luadoc/util.lua +233 -0
  137. data/vendor/lua/lib/lua/luagl.dll +0 -0
  138. data/vendor/lua/lib/lua/luaglu.dll +0 -0
  139. data/vendor/lua/lib/lua/luaidl.lua +113 -0
  140. data/vendor/lua/lib/lua/luaidl/lex.lua +793 -0
  141. data/vendor/lua/lib/lua/luaidl/pre.lua +149 -0
  142. data/vendor/lua/lib/lua/luaidl/sin.lua +3631 -0
  143. data/vendor/lua/lib/lua/luarocks/add.lua +108 -0
  144. data/vendor/lua/lib/lua/luarocks/admin_remove.lua +87 -0
  145. data/vendor/lua/lib/lua/luarocks/build.lua +330 -0
  146. data/vendor/lua/lib/lua/luarocks/build/builtin.lua +253 -0
  147. data/vendor/lua/lib/lua/luarocks/build/cmake.lua +54 -0
  148. data/vendor/lua/lib/lua/luarocks/build/command.lua +32 -0
  149. data/vendor/lua/lib/lua/luarocks/build/make.lua +92 -0
  150. data/vendor/lua/lib/lua/luarocks/cache.lua +85 -0
  151. data/vendor/lua/lib/lua/luarocks/cfg.lua +449 -0
  152. data/vendor/lua/lib/lua/luarocks/command_line.lua +163 -0
  153. data/vendor/lua/lib/lua/luarocks/deps.lua +654 -0
  154. data/vendor/lua/lib/lua/luarocks/dir.lua +69 -0
  155. data/vendor/lua/lib/lua/luarocks/download.lua +90 -0
  156. data/vendor/lua/lib/lua/luarocks/fetch.lua +321 -0
  157. data/vendor/lua/lib/lua/luarocks/fetch/cvs.lua +44 -0
  158. data/vendor/lua/lib/lua/luarocks/fetch/git.lua +81 -0
  159. data/vendor/lua/lib/lua/luarocks/fetch/git_file.lua +17 -0
  160. data/vendor/lua/lib/lua/luarocks/fetch/hg.lua +54 -0
  161. data/vendor/lua/lib/lua/luarocks/fetch/sscm.lua +42 -0
  162. data/vendor/lua/lib/lua/luarocks/fetch/svn.lua +53 -0
  163. data/vendor/lua/lib/lua/luarocks/fs.lua +40 -0
  164. data/vendor/lua/lib/lua/luarocks/fs/lua.lua +676 -0
  165. data/vendor/lua/lib/lua/luarocks/fs/unix.lua +88 -0
  166. data/vendor/lua/lib/lua/luarocks/fs/unix/tools.lua +325 -0
  167. data/vendor/lua/lib/lua/luarocks/fs/win32.lua +107 -0
  168. data/vendor/lua/lib/lua/luarocks/fs/win32/tools.lua +334 -0
  169. data/vendor/lua/lib/lua/luarocks/help.lua +101 -0
  170. data/vendor/lua/lib/lua/luarocks/index.lua +172 -0
  171. data/vendor/lua/lib/lua/luarocks/install.lua +151 -0
  172. data/vendor/lua/lib/lua/luarocks/list.lua +35 -0
  173. data/vendor/lua/lib/lua/luarocks/loader.lua +228 -0
  174. data/vendor/lua/lib/lua/luarocks/make.lua +71 -0
  175. data/vendor/lua/lib/lua/luarocks/make_manifest.lua +34 -0
  176. data/vendor/lua/lib/lua/luarocks/manif.lua +360 -0
  177. data/vendor/lua/lib/lua/luarocks/manif_core.lua +75 -0
  178. data/vendor/lua/lib/lua/luarocks/new_version.lua +141 -0
  179. data/vendor/lua/lib/lua/luarocks/pack.lua +205 -0
  180. data/vendor/lua/lib/lua/luarocks/path.lua +315 -0
  181. data/vendor/lua/lib/lua/luarocks/persist.lua +173 -0
  182. data/vendor/lua/lib/lua/luarocks/refresh_cache.lua +30 -0
  183. data/vendor/lua/lib/lua/luarocks/remove.lua +135 -0
  184. data/vendor/lua/lib/lua/luarocks/rep.lua +313 -0
  185. data/vendor/lua/lib/lua/luarocks/require.lua +6 -0
  186. data/vendor/lua/lib/lua/luarocks/search.lua +399 -0
  187. data/vendor/lua/lib/lua/luarocks/show.lua +138 -0
  188. data/vendor/lua/lib/lua/luarocks/site_config.lua +23 -0
  189. data/vendor/lua/lib/lua/luarocks/tools/patch.lua +712 -0
  190. data/vendor/lua/lib/lua/luarocks/tools/tar.lua +144 -0
  191. data/vendor/lua/lib/lua/luarocks/tools/zip.lua +245 -0
  192. data/vendor/lua/lib/lua/luarocks/type_check.lua +267 -0
  193. data/vendor/lua/lib/lua/luarocks/unpack.lua +151 -0
  194. data/vendor/lua/lib/lua/luarocks/util.lua +420 -0
  195. data/vendor/lua/lib/lua/luarocks/validate.lua +164 -0
  196. data/vendor/lua/lib/lua/luars232.dll +0 -0
  197. data/vendor/lua/lib/lua/luasql/mysql.dll +0 -0
  198. data/vendor/lua/lib/lua/luasql/postgres.dll +0 -0
  199. data/vendor/lua/lib/lua/luasql/sqlite3.dll +0 -0
  200. data/vendor/lua/lib/lua/luaunit.lua +601 -0
  201. data/vendor/lua/lib/lua/lxp.dll +0 -0
  202. data/vendor/lua/lib/lua/lxp/lom.lua +60 -0
  203. data/vendor/lua/lib/lua/math_ext.lua +27 -0
  204. data/vendor/lua/lib/lua/mbox.lua +53 -0
  205. data/vendor/lua/lib/lua/md5.lua +19 -0
  206. data/vendor/lua/lib/lua/md5/core.dll +0 -0
  207. data/vendor/lua/lib/lua/metalua.lua +0 -0
  208. data/vendor/lua/lib/lua/metalua/ast_to_string.mlua +553 -0
  209. data/vendor/lua/lib/lua/metalua/base.lua +104 -0
  210. data/vendor/lua/lib/lua/metalua/bytecode.lua +0 -0
  211. data/vendor/lua/lib/lua/metalua/clopts.mlua +204 -0
  212. data/vendor/lua/lib/lua/metalua/compiler.lua +3 -0
  213. data/vendor/lua/lib/lua/metalua/dollar.mlua +24 -0
  214. data/vendor/lua/lib/lua/metalua/extension/H-runtime.mlua +216 -0
  215. data/vendor/lua/lib/lua/metalua/extension/H.mlua +22 -0
  216. data/vendor/lua/lib/lua/metalua/extension/anaphoric.mlua +54 -0
  217. data/vendor/lua/lib/lua/metalua/extension/clist.mlua +149 -0
  218. data/vendor/lua/lib/lua/metalua/extension/continue.mlua +53 -0
  219. data/vendor/lua/lib/lua/metalua/extension/localin.mlua +2 -0
  220. data/vendor/lua/lib/lua/metalua/extension/log.mlua +39 -0
  221. data/vendor/lua/lib/lua/metalua/extension/match.mlua +374 -0
  222. data/vendor/lua/lib/lua/metalua/extension/ternary.mlua +10 -0
  223. data/vendor/lua/lib/lua/metalua/extension/trycatch.mlua +189 -0
  224. data/vendor/lua/lib/lua/metalua/extension/types-runtime.mlua +159 -0
  225. data/vendor/lua/lib/lua/metalua/extension/types.mlua +352 -0
  226. data/vendor/lua/lib/lua/metalua/extension/withdo.mlua +30 -0
  227. data/vendor/lua/lib/lua/metalua/extension/xglobal-runtime.lua +41 -0
  228. data/vendor/lua/lib/lua/metalua/extension/xglobal.mlua +20 -0
  229. data/vendor/lua/lib/lua/metalua/extension/xloop.mlua +100 -0
  230. data/vendor/lua/lib/lua/metalua/extension/xmatch.mlua +216 -0
  231. data/vendor/lua/lib/lua/metalua/metaloop.mlua +76 -0
  232. data/vendor/lua/lib/lua/metalua/mlc.lua +0 -0
  233. data/vendor/lua/lib/lua/metalua/mlc_xcall.lua +119 -0
  234. data/vendor/lua/lib/lua/metalua/mlp.lua +0 -0
  235. data/vendor/lua/lib/lua/metalua/package2.lua +101 -0
  236. data/vendor/lua/lib/lua/metalua/runtime.lua +3 -0
  237. data/vendor/lua/lib/lua/metalua/string2.lua +44 -0
  238. data/vendor/lua/lib/lua/metalua/table2.lua +372 -0
  239. data/vendor/lua/lib/lua/metalua/walk.mlua +304 -0
  240. data/vendor/lua/lib/lua/metalua/walk/bindings.mlua +41 -0
  241. data/vendor/lua/lib/lua/metalua/walk/id.mlua +186 -0
  242. data/vendor/lua/lib/lua/metalua/walk/scope.lua +54 -0
  243. data/vendor/lua/lib/lua/mime.lua +87 -0
  244. data/vendor/lua/lib/lua/mime/core.dll +0 -0
  245. data/vendor/lua/lib/lua/mobdebug.lua +1484 -0
  246. data/vendor/lua/lib/lua/modules.lua +16 -0
  247. data/vendor/lua/lib/lua/object.lua +56 -0
  248. data/vendor/lua/lib/lua/oil/Exception.lua +26 -0
  249. data/vendor/lua/lib/lua/oil/arch.lua +27 -0
  250. data/vendor/lua/lib/lua/oil/arch/basic/client.lua +29 -0
  251. data/vendor/lua/lib/lua/oil/arch/basic/common.lua +13 -0
  252. data/vendor/lua/lib/lua/oil/arch/basic/server.lua +27 -0
  253. data/vendor/lua/lib/lua/oil/arch/cooperative/common.lua +10 -0
  254. data/vendor/lua/lib/lua/oil/arch/cooperative/server.lua +16 -0
  255. data/vendor/lua/lib/lua/oil/arch/corba/client.lua +39 -0
  256. data/vendor/lua/lib/lua/oil/arch/corba/common.lua +58 -0
  257. data/vendor/lua/lib/lua/oil/arch/corba/intercepted/client.lua +9 -0
  258. data/vendor/lua/lib/lua/oil/arch/corba/intercepted/server.lua +9 -0
  259. data/vendor/lua/lib/lua/oil/arch/corba/server.lua +35 -0
  260. data/vendor/lua/lib/lua/oil/arch/ludo/byref.lua +18 -0
  261. data/vendor/lua/lib/lua/oil/arch/ludo/client.lua +19 -0
  262. data/vendor/lua/lib/lua/oil/arch/ludo/common.lua +18 -0
  263. data/vendor/lua/lib/lua/oil/arch/ludo/server.lua +19 -0
  264. data/vendor/lua/lib/lua/oil/arch/typed/client.lua +27 -0
  265. data/vendor/lua/lib/lua/oil/arch/typed/common.lua +9 -0
  266. data/vendor/lua/lib/lua/oil/arch/typed/server.lua +18 -0
  267. data/vendor/lua/lib/lua/oil/assert.lua +87 -0
  268. data/vendor/lua/lib/lua/oil/builder.lua +45 -0
  269. data/vendor/lua/lib/lua/oil/builder/basic/client.lua +31 -0
  270. data/vendor/lua/lib/lua/oil/builder/basic/common.lua +11 -0
  271. data/vendor/lua/lib/lua/oil/builder/basic/server.lua +13 -0
  272. data/vendor/lua/lib/lua/oil/builder/cooperative/common.lua +11 -0
  273. data/vendor/lua/lib/lua/oil/builder/cooperative/server.lua +11 -0
  274. data/vendor/lua/lib/lua/oil/builder/corba/client.lua +13 -0
  275. data/vendor/lua/lib/lua/oil/builder/corba/common.lua +24 -0
  276. data/vendor/lua/lib/lua/oil/builder/corba/gencode.lua +13 -0
  277. data/vendor/lua/lib/lua/oil/builder/corba/intercepted/client.lua +11 -0
  278. data/vendor/lua/lib/lua/oil/builder/corba/intercepted/server.lua +11 -0
  279. data/vendor/lua/lib/lua/oil/builder/corba/server.lua +13 -0
  280. data/vendor/lua/lib/lua/oil/builder/lua/client.lua +11 -0
  281. data/vendor/lua/lib/lua/oil/builder/lua/server.lua +12 -0
  282. data/vendor/lua/lib/lua/oil/builder/ludo/byref.lua +13 -0
  283. data/vendor/lua/lib/lua/oil/builder/ludo/client.lua +13 -0
  284. data/vendor/lua/lib/lua/oil/builder/ludo/common.lua +14 -0
  285. data/vendor/lua/lib/lua/oil/builder/ludo/server.lua +13 -0
  286. data/vendor/lua/lib/lua/oil/builder/typed/client.lua +16 -0
  287. data/vendor/lua/lib/lua/oil/builder/typed/server.lua +12 -0
  288. data/vendor/lua/lib/lua/oil/compat.lua +846 -0
  289. data/vendor/lua/lib/lua/oil/component.lua +1 -0
  290. data/vendor/lua/lib/lua/oil/corba/giop.lua +301 -0
  291. data/vendor/lua/lib/lua/oil/corba/giop/Codec.lua +1568 -0
  292. data/vendor/lua/lib/lua/oil/corba/giop/CodecGen.lua +589 -0
  293. data/vendor/lua/lib/lua/oil/corba/giop/Exception.lua +25 -0
  294. data/vendor/lua/lib/lua/oil/corba/giop/Indexer.lua +63 -0
  295. data/vendor/lua/lib/lua/oil/corba/giop/Listener.lua +343 -0
  296. data/vendor/lua/lib/lua/oil/corba/giop/Messenger.lua +228 -0
  297. data/vendor/lua/lib/lua/oil/corba/giop/Referrer.lua +180 -0
  298. data/vendor/lua/lib/lua/oil/corba/giop/Requester.lua +462 -0
  299. data/vendor/lua/lib/lua/oil/corba/idl.lua +597 -0
  300. data/vendor/lua/lib/lua/oil/corba/idl/Compiler.lua +133 -0
  301. data/vendor/lua/lib/lua/oil/corba/idl/Importer.lua +235 -0
  302. data/vendor/lua/lib/lua/oil/corba/idl/Indexer.lua +95 -0
  303. data/vendor/lua/lib/lua/oil/corba/idl/Registry.lua +1821 -0
  304. data/vendor/lua/lib/lua/oil/corba/idl/ir.lua +847 -0
  305. data/vendor/lua/lib/lua/oil/corba/idl/sysex.lua +21 -0
  306. data/vendor/lua/lib/lua/oil/corba/iiop/Profiler.lua +200 -0
  307. data/vendor/lua/lib/lua/oil/corba/intercepted/Listener.lua +158 -0
  308. data/vendor/lua/lib/lua/oil/corba/intercepted/Requester.lua +181 -0
  309. data/vendor/lua/lib/lua/oil/corba/services/event.lua +126 -0
  310. data/vendor/lua/lib/lua/oil/corba/services/event/ConsumerAdmin.lua +50 -0
  311. data/vendor/lua/lib/lua/oil/corba/services/event/EventFactory.lua +15 -0
  312. data/vendor/lua/lib/lua/oil/corba/services/event/EventQueue.lua +37 -0
  313. data/vendor/lua/lib/lua/oil/corba/services/event/ProxyPushConsumer.lua +75 -0
  314. data/vendor/lua/lib/lua/oil/corba/services/event/ProxyPushSupplier.lua +62 -0
  315. data/vendor/lua/lib/lua/oil/corba/services/event/SingleDeferredDispatcher.lua +60 -0
  316. data/vendor/lua/lib/lua/oil/corba/services/event/SingleSynchronousDispatcher.lua +39 -0
  317. data/vendor/lua/lib/lua/oil/corba/services/event/SupplierAdmin.lua +50 -0
  318. data/vendor/lua/lib/lua/oil/corba/services/naming.lua +436 -0
  319. data/vendor/lua/lib/lua/oil/kernel/base/Acceptor.lua +268 -0
  320. data/vendor/lua/lib/lua/oil/kernel/base/Channels.lua +121 -0
  321. data/vendor/lua/lib/lua/oil/kernel/base/Connector.lua +147 -0
  322. data/vendor/lua/lib/lua/oil/kernel/base/Dispatcher.lua +99 -0
  323. data/vendor/lua/lib/lua/oil/kernel/base/Proxies.lua +86 -0
  324. data/vendor/lua/lib/lua/oil/kernel/base/Proxies/asynchronous.lua +56 -0
  325. data/vendor/lua/lib/lua/oil/kernel/base/Proxies/protected.lua +17 -0
  326. data/vendor/lua/lib/lua/oil/kernel/base/Proxies/synchronous.lua +17 -0
  327. data/vendor/lua/lib/lua/oil/kernel/base/Proxies/utils.lua +29 -0
  328. data/vendor/lua/lib/lua/oil/kernel/base/Receiver.lua +110 -0
  329. data/vendor/lua/lib/lua/oil/kernel/base/Servants.lua +207 -0
  330. data/vendor/lua/lib/lua/oil/kernel/base/Sockets.lua +44 -0
  331. data/vendor/lua/lib/lua/oil/kernel/cooperative/Receiver.lua +139 -0
  332. data/vendor/lua/lib/lua/oil/kernel/intercepted/Listener.lua +47 -0
  333. data/vendor/lua/lib/lua/oil/kernel/intercepted/Requester.lua +58 -0
  334. data/vendor/lua/lib/lua/oil/kernel/lua/Dispatcher.lua +76 -0
  335. data/vendor/lua/lib/lua/oil/kernel/lua/Proxies.lua +69 -0
  336. data/vendor/lua/lib/lua/oil/kernel/typed/Dispatcher.lua +91 -0
  337. data/vendor/lua/lib/lua/oil/kernel/typed/Proxies.lua +153 -0
  338. data/vendor/lua/lib/lua/oil/kernel/typed/Servants.lua +137 -0
  339. data/vendor/lua/lib/lua/oil/ludo/Codec.lua +66 -0
  340. data/vendor/lua/lib/lua/oil/ludo/CodecByRef.lua +103 -0
  341. data/vendor/lua/lib/lua/oil/ludo/Listener.lua +151 -0
  342. data/vendor/lua/lib/lua/oil/ludo/Referrer.lua +72 -0
  343. data/vendor/lua/lib/lua/oil/ludo/Requester.lua +107 -0
  344. data/vendor/lua/lib/lua/oil/oo.lua +1 -0
  345. data/vendor/lua/lib/lua/oil/port.lua +1 -0
  346. data/vendor/lua/lib/lua/oil/properties.lua +57 -0
  347. data/vendor/lua/lib/lua/oil/verbose.lua +133 -0
  348. data/vendor/lua/lib/lua/package_ext.lua +15 -0
  349. data/vendor/lua/lib/lua/parser.lua +268 -0
  350. data/vendor/lua/lib/lua/pl/Date.lua +555 -0
  351. data/vendor/lua/lib/lua/pl/List.lua +613 -0
  352. data/vendor/lua/lib/lua/pl/Map.lua +113 -0
  353. data/vendor/lua/lib/lua/pl/MultiMap.lua +62 -0
  354. data/vendor/lua/lib/lua/pl/OrderedMap.lua +151 -0
  355. data/vendor/lua/lib/lua/pl/Set.lua +153 -0
  356. data/vendor/lua/lib/lua/pl/app.lua +165 -0
  357. data/vendor/lua/lib/lua/pl/array2d.lua +501 -0
  358. data/vendor/lua/lib/lua/pl/class.lua +180 -0
  359. data/vendor/lua/lib/lua/pl/comprehension.lua +286 -0
  360. data/vendor/lua/lib/lua/pl/config.lua +176 -0
  361. data/vendor/lua/lib/lua/pl/data.lua +606 -0
  362. data/vendor/lua/lib/lua/pl/dir.lua +475 -0
  363. data/vendor/lua/lib/lua/pl/file.lua +70 -0
  364. data/vendor/lua/lib/lua/pl/func.lua +376 -0
  365. data/vendor/lua/lib/lua/pl/init.lua +68 -0
  366. data/vendor/lua/lib/lua/pl/input.lua +173 -0
  367. data/vendor/lua/lib/lua/pl/lapp.lua +407 -0
  368. data/vendor/lua/lib/lua/pl/lexer.lua +456 -0
  369. data/vendor/lua/lib/lua/pl/luabalanced.lua +264 -0
  370. data/vendor/lua/lib/lua/pl/operator.lua +201 -0
  371. data/vendor/lua/lib/lua/pl/path.lua +398 -0
  372. data/vendor/lua/lib/lua/pl/permute.lua +63 -0
  373. data/vendor/lua/lib/lua/pl/platf/luajava.lua +101 -0
  374. data/vendor/lua/lib/lua/pl/pretty.lua +285 -0
  375. data/vendor/lua/lib/lua/pl/seq.lua +551 -0
  376. data/vendor/lua/lib/lua/pl/sip.lua +344 -0
  377. data/vendor/lua/lib/lua/pl/strict.lua +70 -0
  378. data/vendor/lua/lib/lua/pl/stringio.lua +158 -0
  379. data/vendor/lua/lib/lua/pl/stringx.lua +440 -0
  380. data/vendor/lua/lib/lua/pl/tablex.lua +817 -0
  381. data/vendor/lua/lib/lua/pl/template.lua +103 -0
  382. data/vendor/lua/lib/lua/pl/test.lua +135 -0
  383. data/vendor/lua/lib/lua/pl/text.lua +243 -0
  384. data/vendor/lua/lib/lua/pl/utils.lua +550 -0
  385. data/vendor/lua/lib/lua/pl/xml.lua +689 -0
  386. data/vendor/lua/lib/lua/profiler.dll +0 -0
  387. data/vendor/lua/lib/lua/re.lua +248 -0
  388. data/vendor/lua/lib/lua/rex_onig.dll +0 -0
  389. data/vendor/lua/lib/lua/rex_pcre.dll +0 -0
  390. data/vendor/lua/lib/lua/rex_posix.dll +0 -0
  391. data/vendor/lua/lib/lua/rings.dll +0 -0
  392. data/vendor/lua/lib/lua/serialize.lua +193 -0
  393. data/vendor/lua/lib/lua/set.lua +149 -0
  394. data/vendor/lua/lib/lua/socket.lua +133 -0
  395. data/vendor/lua/lib/lua/socket/core.dll +0 -0
  396. data/vendor/lua/lib/lua/socket/ftp.lua +281 -0
  397. data/vendor/lua/lib/lua/socket/http.lua +350 -0
  398. data/vendor/lua/lib/lua/socket/smtp.lua +251 -0
  399. data/vendor/lua/lib/lua/socket/tp.lua +123 -0
  400. data/vendor/lua/lib/lua/socket/url.lua +297 -0
  401. data/vendor/lua/lib/lua/ssl.dll +0 -0
  402. data/vendor/lua/lib/lua/ssl.lua +93 -0
  403. data/vendor/lua/lib/lua/ssl/https.lua +138 -0
  404. data/vendor/lua/lib/lua/stable.lua +28 -0
  405. data/vendor/lua/lib/lua/std.lua +16 -0
  406. data/vendor/lua/lib/lua/strbuf.lua +32 -0
  407. data/vendor/lua/lib/lua/strict.lua +45 -0
  408. data/vendor/lua/lib/lua/string_ext.lua +274 -0
  409. data/vendor/lua/lib/lua/table_ext.lua +117 -0
  410. data/vendor/lua/lib/lua/tar.lua +262 -0
  411. data/vendor/lua/lib/lua/task.dll +0 -0
  412. data/vendor/lua/lib/lua/tree.lua +81 -0
  413. data/vendor/lua/lib/lua/unicode.dll +0 -0
  414. data/vendor/lua/lib/lua/verbose_require.lua +11 -0
  415. data/vendor/lua/lib/lua/vstruct.lua +86 -0
  416. data/vendor/lua/lib/lua/vstruct/ast.lua +192 -0
  417. data/vendor/lua/lib/lua/vstruct/ast/Bitpack.lua +33 -0
  418. data/vendor/lua/lib/lua/vstruct/ast/Generator.lua +174 -0
  419. data/vendor/lua/lib/lua/vstruct/ast/IO.lua +45 -0
  420. data/vendor/lua/lib/lua/vstruct/ast/List.lua +56 -0
  421. data/vendor/lua/lib/lua/vstruct/ast/Name.lua +20 -0
  422. data/vendor/lua/lib/lua/vstruct/ast/Repeat.lua +23 -0
  423. data/vendor/lua/lib/lua/vstruct/ast/Root.lua +19 -0
  424. data/vendor/lua/lib/lua/vstruct/ast/Table.lua +65 -0
  425. data/vendor/lua/lib/lua/vstruct/cursor.lua +81 -0
  426. data/vendor/lua/lib/lua/vstruct/io.lua +45 -0
  427. data/vendor/lua/lib/lua/vstruct/io/a.lua +24 -0
  428. data/vendor/lua/lib/lua/vstruct/io/b.lua +28 -0
  429. data/vendor/lua/lib/lua/vstruct/io/bigendian.lua +21 -0
  430. data/vendor/lua/lib/lua/vstruct/io/c.lua +25 -0
  431. data/vendor/lua/lib/lua/vstruct/io/defaults.lua +24 -0
  432. data/vendor/lua/lib/lua/vstruct/io/endianness.lua +41 -0
  433. data/vendor/lua/lib/lua/vstruct/io/f.lua +129 -0
  434. data/vendor/lua/lib/lua/vstruct/io/hostendian.lua +21 -0
  435. data/vendor/lua/lib/lua/vstruct/io/i.lua +42 -0
  436. data/vendor/lua/lib/lua/vstruct/io/littleendian.lua +21 -0
  437. data/vendor/lua/lib/lua/vstruct/io/m.lua +62 -0
  438. data/vendor/lua/lib/lua/vstruct/io/p.lua +23 -0
  439. data/vendor/lua/lib/lua/vstruct/io/s.lua +27 -0
  440. data/vendor/lua/lib/lua/vstruct/io/seekb.lua +18 -0
  441. data/vendor/lua/lib/lua/vstruct/io/seekf.lua +18 -0
  442. data/vendor/lua/lib/lua/vstruct/io/seekto.lua +18 -0
  443. data/vendor/lua/lib/lua/vstruct/io/u.lua +54 -0
  444. data/vendor/lua/lib/lua/vstruct/io/x.lua +34 -0
  445. data/vendor/lua/lib/lua/vstruct/io/z.lua +63 -0
  446. data/vendor/lua/lib/lua/vstruct/lexer.lua +100 -0
  447. data/vendor/lua/lib/lua/vstruct/pack.lua +142 -0
  448. data/vendor/lua/lib/lua/vstruct/test.lua +47 -0
  449. data/vendor/lua/lib/lua/vstruct/test/basic.lua +73 -0
  450. data/vendor/lua/lib/lua/vstruct/test/common.lua +100 -0
  451. data/vendor/lua/lib/lua/vstruct/test/fp-bigendian.lua +56 -0
  452. data/vendor/lua/lib/lua/vstruct/test/fp-littleendian.lua +56 -0
  453. data/vendor/lua/lib/lua/vstruct/test/struct-test-gen.lua +1230 -0
  454. data/vendor/lua/lib/lua/vstruct/unpack.lua +126 -0
  455. data/vendor/lua/lib/lua/wx.dll +0 -0
  456. data/vendor/lua/lib/lua/xml.lua +75 -0
  457. data/vendor/lua/lib/lua/zip.dll +0 -0
  458. data/vendor/lua/lib/lua/zlib.dll +0 -0
  459. metadata +529 -0
@@ -0,0 +1,57 @@
1
+ -------------------------------------------------------------------------------
2
+ -- Coroutine safe xpcall and pcall versions
3
+ --
4
+ -- Encapsulates the protected calls with a coroutine based loop, so errors can
5
+ -- be dealed without the usual Lua 5.x pcall/xpcall issues with coroutines
6
+ -- yielding inside the call to pcall or xpcall.
7
+ --
8
+ -- Authors: Roberto Ierusalimschy and Andre Carregal
9
+ -- Contributors: Thomas Harning Jr., Ignacio Burgue�o, F�bio Mascarenhas
10
+ --
11
+ -- Copyright 2005 - Kepler Project (www.keplerproject.org)
12
+ --
13
+ -- $Id: coxpcall.lua,v 1.13 2008/05/19 19:20:02 mascarenhas Exp $
14
+ -------------------------------------------------------------------------------
15
+
16
+ -------------------------------------------------------------------------------
17
+ -- Implements xpcall with coroutines
18
+ -------------------------------------------------------------------------------
19
+ local performResume, handleReturnValue
20
+ local oldpcall, oldxpcall = pcall, xpcall
21
+
22
+ function handleReturnValue(err, co, status, ...)
23
+ if not status then
24
+ return false, err(debug.traceback(co, (...)), ...)
25
+ end
26
+ if coroutine.status(co) == 'suspended' then
27
+ return performResume(err, co, coroutine.yield(...))
28
+ else
29
+ return true, ...
30
+ end
31
+ end
32
+
33
+ function performResume(err, co, ...)
34
+ return handleReturnValue(err, co, coroutine.resume(co, ...))
35
+ end
36
+
37
+ function coxpcall(f, err, ...)
38
+ local res, co = oldpcall(coroutine.create, f)
39
+ if not res then
40
+ local params = {...}
41
+ local newf = function() return f(unpack(params)) end
42
+ co = coroutine.create(newf)
43
+ end
44
+ return performResume(err, co, ...)
45
+ end
46
+
47
+ -------------------------------------------------------------------------------
48
+ -- Implements pcall with coroutines
49
+ -------------------------------------------------------------------------------
50
+
51
+ local function id(trace, ...)
52
+ return ...
53
+ end
54
+
55
+ function copcall(f, ...)
56
+ return coxpcall(f, id, ...)
57
+ end
@@ -0,0 +1,745 @@
1
+ --[[LuaDate version:2.0.1]]-------------------------------
2
+ --[[------------------------------------------------------
3
+ Copyright (C) 2006, by Jas Latrix (jastejada@yahoo.com)
4
+ All Rights Deserved.
5
+ use this code at your own risk!.
6
+ keep out of reach of children.
7
+ --]]------------------------------------------------------
8
+ --[[ CONSTANTS ]]--
9
+ local HOURPERDAY = 24
10
+ local MINPERHOUR = 60
11
+ local MINPERDAY = 1440 -- 24*60
12
+ local SECPERMIN = 60
13
+ local SECPERHOUR = 3600 -- 60*60
14
+ local SECPERDAY = 86400 -- 24*60*60
15
+ local TICKSPERSEC = 1000000
16
+ local TICKSPERDAY = 86400000000
17
+ local TICKSPERHOUR = 3600000000
18
+ local TICKSPERMIN = 60000000
19
+ local DAYNUM_MAX = 365242500 -- Sat Jan 01 1000000 00:00:00
20
+ local DAYNUM_MIN = -365242500 -- Mon Jan 01 1000000 BCE 00:00:00
21
+ local DAYNUM_DEF = 0 -- Mon Jan 01 0001 00:00:00
22
+ local _;
23
+ --[[ LOCAL ARE FASTER ]]--
24
+ local type = type
25
+ local pairs = pairs
26
+ local error = error
27
+ local assert = assert
28
+ local tonumber = tonumber
29
+ local tostring = tostring
30
+ local string = string
31
+ local math = math
32
+ local os = os
33
+ local unpack = unpack
34
+ local setmetatable = setmetatable
35
+ local getmetatable = getmetatable
36
+ --[[ EXTRA FUNCTIONS ]]--
37
+ local fmt = string.format
38
+ local lwr = string.lower
39
+ local upr = string.upper
40
+ local rep = string.rep
41
+ local len = string.len
42
+ local sub = string.sub
43
+ local gsub = string.gsub
44
+ local gmatch = string.gmatch or string.gfind
45
+ local find = string.find
46
+ local ostime = os.time
47
+ local osdate = os.date
48
+ local floor = math.floor
49
+ local ceil = math.ceil
50
+ local abs = math.abs
51
+ -- removes the decimal part of a number
52
+ local function fix(n) n = tonumber(n) return n and ((n > 0 and floor or ceil)(n)) end
53
+ -- returns the modulo n % d;
54
+ local function mod (n,d) return n - d*floor(n/d) end
55
+ -- rounds a number;
56
+ local function round(n, d) d=d^10 return floor((n*d)+.5)/d end
57
+ -- rounds a number to whole;
58
+ local function whole(n)return floor(n+.5)end
59
+ -- is `str` in string list `tbl`, `ml` is the minimun len
60
+ local function inlist(str, tbl, ml, tn)
61
+ local sl = len(str)
62
+ if sl < (ml or 0) then return nil end
63
+ str = lwr(str)
64
+ for k, v in pairs(tbl) do
65
+ if str == lwr(sub(v, 1, sl)) then
66
+ if tn then tn[0] = k end
67
+ return k
68
+ end
69
+ end
70
+ end
71
+ local function fnil() end
72
+ local function fret(x)return x;end
73
+ --[[ DATE FUNCTIONS ]]--
74
+ local DATE_EPOCH -- to be set later
75
+ local sl_weekdays = {
76
+ [0]="Sunday",[1]="Monday",[2]="Tuesday",[3]="Wednesday",[4]="Thursday",[5]="Friday",[6]="Saturday",
77
+ [7]="Sun",[8]="Mon",[9]="Tue",[10]="Wed",[11]="Thu",[12]="Fri",[13]="Sat",
78
+ }
79
+ local sl_meridian = {[-1]="AM", [1]="PM"}
80
+ local sl_months = {
81
+ [00]="January", [01]="February", [02]="March",
82
+ [03]="April", [04]="May", [05]="June",
83
+ [06]="July", [07]="August", [08]="September",
84
+ [09]="October", [10]="November", [11]="December",
85
+ [12]="Jan", [13]="Feb", [14]="Mar",
86
+ [15]="Apr", [16]="May", [17]="Jun",
87
+ [18]="Jul", [19]="Aug", [20]="Sep",
88
+ [21]="Oct", [22]="Nov", [23]="Dec",
89
+ }
90
+ -- added the '.2' to avoid collision, use `fix` to remove
91
+ local sl_timezone = {
92
+ [000]="utc", [0.2]="gmt",
93
+ [300]="est", [240]="edt",
94
+ [360]="cst", [300.2]="cdt",
95
+ [420]="mst", [360.2]="mdt",
96
+ [480]="pst", [420.2]="pdt",
97
+ }
98
+ -- set the day fraction resolution
99
+ local function setticks(t)
100
+ TICKSPERSEC = t;
101
+ TICKSPERDAY = SECPERDAY*TICKSPERSEC
102
+ TICKSPERHOUR= SECPERHOUR*TICKSPERSEC
103
+ TICKSPERMIN = SECPERMIN*TICKSPERSEC
104
+ end
105
+ -- is year y leap year?
106
+ local function isleapyear(y) -- y must be int!
107
+ return (mod(y, 4) == 0 and (mod(y, 100) ~= 0 or mod(y, 400) == 0))
108
+ end
109
+ -- day since year 0
110
+ local function dayfromyear(y) -- y must be int!
111
+ return 365*y + floor(y/4) - floor(y/100) + floor(y/400)
112
+ end
113
+ -- day number from date, month is zero base
114
+ local function makedaynum(y, m, d)
115
+ local mm = mod(mod(m,12) + 10, 12)
116
+ return dayfromyear(y + floor(m/12) - floor(mm/10)) + floor((mm*306 + 5)/10) + d - 307
117
+ --local yy = y + floor(m/12) - floor(mm/10)
118
+ --return dayfromyear(yy) + floor((mm*306 + 5)/10) + (d - 1)
119
+ end
120
+ -- date from day number, month is zero base
121
+ local function breakdaynum(g)
122
+ local g = g + 306
123
+ local y = floor((10000*g + 14780)/3652425)
124
+ local d = g - dayfromyear(y)
125
+ if d < 0 then y = y - 1; d = g - dayfromyear(y) end
126
+ local mi = floor((100*d + 52)/3060)
127
+ return (floor((mi + 2)/12) + y), mod(mi + 2,12), (d - floor((mi*306 + 5)/10) + 1)
128
+ end
129
+ --[[ for floats or int32 Lua Number data type
130
+ local function breakdaynum2(g)
131
+ local g, n = g + 306;
132
+ local n400 = floor(g/DI400Y);n = mod(g,DI400Y);
133
+ local n100 = floor(n/DI100Y);n = mod(n,DI100Y);
134
+ local n004 = floor(n/DI4Y); n = mod(n,DI4Y);
135
+ local n001 = floor(n/365); n = mod(n,365);
136
+ local y = (n400*400) + (n100*100) + (n004*4) + n001 - ((n001 == 4 or n100 == 4) and 1 or 0)
137
+ local d = g - dayfromyear(y)
138
+ local mi = floor((100*d + 52)/3060)
139
+ return (floor((mi + 2)/12) + y), mod(mi + 2,12), (d - floor((mi*306 + 5)/10) + 1)
140
+ end
141
+ ]]
142
+ -- day fraction from time
143
+ local function makedayfrc(h,r,s,t)
144
+ return ((h*60 + r)*60 + s)*TICKSPERSEC + t
145
+ end
146
+ -- time from day fraction
147
+ local function breakdayfrc(df)
148
+ return
149
+ mod(floor(df/TICKSPERHOUR),HOURPERDAY),
150
+ mod(floor(df/TICKSPERMIN ),MINPERHOUR),
151
+ mod(floor(df/TICKSPERSEC ),SECPERMIN),
152
+ mod(df,TICKSPERSEC)
153
+ end
154
+ -- weekday sunday = 0, monday = 1 ...
155
+ local function weekday(dn) return mod(dn + 1, 7) end
156
+ -- yearday 0 based ...
157
+ local function yearday(dn)
158
+ return dn - dayfromyear((breakdaynum(dn))-1)
159
+ end
160
+ -- parse v as a month
161
+ local function getmontharg(v)
162
+ local m = tonumber(v);
163
+ return (m and fix(m - 1)) or inlist(tostring(v) or "", sl_months, 2)
164
+ end
165
+ -- get daynum of isoweek one of year y
166
+ local function isow1(y)
167
+ local f = makedaynum(y, 0, 4) -- get the date for the 4-Jan of year `y`
168
+ local d = weekday(f)
169
+ d = d == 0 and 7 or d -- get the ISO day number, 1 == Monday, 7 == Sunday
170
+ return f + (1 - d)
171
+ end
172
+ local function isowy(dn)
173
+ local w1;
174
+ local y = (breakdaynum(dn))
175
+ if dn >= makedaynum(y, 11, 29) then
176
+ w1 = isow1(y + 1);
177
+ if dn < w1 then
178
+ w1 = isow1(y);
179
+ else
180
+ y = y + 1;
181
+ end
182
+ else
183
+ w1 = isow1(y);
184
+ if dn < w1 then
185
+ w1 = isow1(y-1)
186
+ y = y - 1
187
+ end
188
+ end
189
+ return floor((dn-w1)/7)+1, y
190
+ end
191
+ local function isoy(dn)
192
+ local y = (breakdaynum(dn))
193
+ return y + (((dn >= makedaynum(y, 11, 29)) and (dn >= isow1(y + 1))) and 1 or (dn < isow1(y) and -1 or 0))
194
+ end
195
+ local function makedaynum_isoywd(y,w,d)
196
+ return isow1(y) + 7*w + d - 8 -- simplified: isow1(y) + ((w-1)*7) + (d-1)
197
+ end
198
+ --[[ THE DATE MOUDLE ]]--
199
+ local fmtstr = "%x %X";
200
+ --#if not DATE_OBJECT_AFX then
201
+ date = {}
202
+ local date = date
203
+ setmetatable(date, date)
204
+ -- Version: VMMMRRRR; V-Major, M-Minor, R-Revision; e.g. 5.45.321 == 50450321
205
+ date.version = 20000000 -- 2.0.0
206
+ --#end -- not DATE_OBJECT_AFX
207
+ --[[ THE DATE OBJECT ]]--
208
+ local dobj = {}
209
+ dobj.__index = dobj
210
+ dobj.__metatable = dobj
211
+ -- shout invalid arg
212
+ local function date_error_arg() return error("invalid argument(s)",0) end
213
+ -- create new date object
214
+ local function date_new(dn, df)
215
+ return setmetatable({daynum=dn, dayfrc=df}, dobj)
216
+ end
217
+ -- is `v` a date object?
218
+ local function date_isdobj(v)
219
+ return (type(v) == 'table' and getmetatable(v) == dobj) and v
220
+ end
221
+
222
+ --#if not NO_LOCAL_TIME_SUPPORT then
223
+ -- magic year table
224
+ local date_epoch, yt;
225
+ local function getequivyear(y)
226
+ assert(not yt)
227
+ yt = {}
228
+ local de, dw, dy = date_epoch:copy()
229
+ for i = 0, 3000 do
230
+ de:setyear(de:getyear() + 1, 1, 1)
231
+ dy = de:getyear()
232
+ dw = de:getweekday() * (isleapyear(dy) and -1 or 1)
233
+ if not yt[dw] then yt[dw] = dy end --print(de)
234
+ if yt[1] and yt[2] and yt[3] and yt[4] and yt[5] and yt[6] and yt[7] and yt[-1] and yt[-2] and yt[-3] and yt[-4] and yt[-5] and yt[-6] and yt[-7] then
235
+ getequivyear = function(y) return yt[ (weekday(makedaynum(y, 0, 1)) + 1) * (isleapyear(y) and -1 or 1) ] end
236
+ return getequivyear(y)
237
+ end
238
+ end
239
+ end
240
+ -- TimeValue from daynum and dayfrc
241
+ local function dvtotv(dn, df)
242
+ return fix(dn - DATE_EPOCH) * SECPERDAY + (df/1000)
243
+ end
244
+ -- TimeValue from date and time
245
+ local function totv(y,m,d,h,r,s)
246
+ return (makedaynum(y, m, d) - DATE_EPOCH) * SECPERDAY + ((h*60 + r)*60 + s)
247
+ end
248
+ -- TimeValue from TimeTable
249
+ local function tmtotv(tm)
250
+ return tm and totv(tm.year, tm.month - 1, tm.day, tm.hour, tm.min, tm.sec)
251
+ end
252
+ -- Returns the bias in seconds of utc time daynum and dayfrc
253
+ local function getbiasutc2(self)
254
+ local y,m,d = breakdaynum(self.daynum)
255
+ local h,r,s = breakdayfrc(self.dayfrc)
256
+ local tvu = totv(y,m,d,h,r,s) -- get the utc TimeValue of date and time
257
+ local tml = osdate("*t", tvu) -- get the local TimeTable of tvu
258
+ if (not tml) or (tml.year > (y+1) or tml.year < (y-1)) then -- failed try the magic
259
+ y = getequivyear(y)
260
+ tvu = totv(y,m,d,h,r,s)
261
+ tml = osdate("*t", tvu)
262
+ end
263
+ local tvl = tmtotv(tml)
264
+ if tvu and tvl then
265
+ return tvu - tvl, tvu, tvl
266
+ else
267
+ return error("failed to get bias from utc time")
268
+ end
269
+ end
270
+ -- Returns the bias in seconds of local time daynum and dayfrc
271
+ local function getbiasloc2(daynum, dayfrc)
272
+ local tvu
273
+ -- extract date and time
274
+ local y,m,d = breakdaynum(daynum)
275
+ local h,r,s = breakdayfrc(dayfrc)
276
+ -- get equivalent TimeTable
277
+ local tml = {year=y, month=m+1, day=d, hour=h, min=r, sec=s}
278
+ -- get equivalent TimeValue
279
+ local tvl = tmtotv(tml)
280
+
281
+ local function chkutc()
282
+ tml.isdst = nil; local tvug = ostime(tml) if tvug and (tvl == tmtotv(osdate("*t", tvug))) then tvu = tvug return end
283
+ tml.isdst = true; local tvud = ostime(tml) if tvud and (tvl == tmtotv(osdate("*t", tvud))) then tvu = tvud return end
284
+ tvu = tvud or tvug
285
+ end
286
+ chkutc()
287
+ if not tvu then
288
+ tml.year = getequivyear(y)
289
+ tvl = tmtotv(tml)
290
+ chkutc()
291
+ end
292
+ return ((tvu and tvl) and (tvu - tvl)) or error("failed to get bias from local time"), tvu, tvl
293
+ end
294
+ --#end -- not NO_LOCAL_TIME_SUPPORT
295
+
296
+ --#if not DATE_OBJECT_AFX then
297
+ -- the date parser
298
+ local strwalker = {} -- ^Lua regular expression is not as powerful as Perl$
299
+ strwalker.__index = strwalker
300
+ local function newstrwalker(s)return setmetatable({s=s, i=1, e=1, c=len(s)}, strwalker) end
301
+ function strwalker:aimchr() return "\n" .. self.s .. "\n" .. rep(".",self.e-1) .. "^" end
302
+ function strwalker:finish() return self.i > self.c end
303
+ function strwalker:back() self.i = self.e return self end
304
+ function strwalker:restart() self.i, self.e = 1, 1 return self end
305
+ function strwalker:match(s) return (find(self.s, s, self.i)) end
306
+ function strwalker:__call(s, f)-- print("strwalker:__call "..s..self:aimchr())
307
+ local is, ie; is, ie, self[1], self[2], self[3], self[4], self[5] = find(self.s, s, self.i)
308
+ if is then self.e, self.i = self.i, 1+ie; if f then f(unpack(self)) end return self end
309
+ end
310
+ local function date_parse(str)
311
+ local y,m,d, h,r,s, z, w,u, j, e, k, x,v,c, chkfin, dn,df;
312
+ local sw = newstrwalker(gsub(gsub(str, "(%b())", ""),"^(%s*)","")) -- remove comment, trim leading space
313
+ --local function error_out() print(y,m,d,h,r,s) end
314
+ local function error_dup(q) --[[error_out()]] error("duplicate value: " .. (q or "") .. sw:aimchr()) end
315
+ local function error_syn(q) --[[error_out()]] error("syntax error: " .. (q or "") .. sw:aimchr()) end
316
+ local function error_inv(q) --[[error_out()]] error("invalid date: " .. (q or "") .. sw:aimchr()) end
317
+ local function sety(q) y = y and error_dup() or tonumber(q); end
318
+ local function setm(q) m = (m or w or j) and error_dup(m or w or j) or tonumber(q) end
319
+ local function setd(q) d = d and error_dup() or tonumber(q) end
320
+ local function seth(q) h = h and error_dup() or tonumber(q) end
321
+ local function setr(q) r = r and error_dup() or tonumber(q) end
322
+ local function sets(q) s = s and error_dup() or tonumber(q) end
323
+ local function adds(q) s = s + tonumber(q) end
324
+ local function setj(q) j = (m or w or j) and error_dup() or tonumber(q); end
325
+ local function setz(q) z = (z ~= 0 and z) and error_dup() or q end
326
+ local function setzn(zs,zn) zn = tonumber(zn); setz( ((zn<24) and (zn*60) or (mod(zn,100) + floor(zn/100) * 60))*( zs=='+' and -1 or 1) ) end
327
+ local function setzc(zs,zh,zm) setz( ((tonumber(zh)*60) + tonumber(zm))*( zs=='+' and -1 or 1) ) end
328
+
329
+ if not (sw("^(%d%d%d%d)",sety) and (sw("^(%-?)(%d%d)%1(%d%d)",function(_,a,b) setm(tonumber(a)); setd(tonumber(b)) end) or sw("^(%-?)[Ww](%d%d)%1(%d?)",function(_,a,b) w, u = tonumber(a), tonumber(b or 1) end) or sw("^%-?(%d%d%d)",setj) or sw("^%-?(%d%d)",function(a) setm(a);setd(1) end))
330
+ and ((sw("^%s*[Tt]?(%d%d):?",seth) and sw("^(%d%d):?",setr) and sw("^(%d%d)",sets) and sw("^(%.%d+)",adds))
331
+ or sw:finish() or (sw"^%s*$" or sw"^%s*[Zz]%s*$" or sw("^%s-([%+%-])(%d%d):?(%d%d)%s*$",setzc) or sw("^%s*([%+%-])(%d%d)%s*$",setzn))
332
+ ) )
333
+ then --print(y,m,d,h,r,s,z,w,u,j)
334
+ sw:restart(); y,m,d,h,r,s,z,w,u,j = nil;
335
+ repeat -- print(sw:aimchr())
336
+ if sw("^[tT:]?%s*(%d%d?):",seth) then --print("$Time")
337
+ _ = sw("^%s*(%d%d?)",setr) and sw("^%s*:%s*(%d%d?)",sets) and sw("^(%.%d+)",adds)
338
+ elseif sw("^(%d+)[/\\%s,-]?%s*") then --print("$Digits")
339
+ x, c = tonumber(sw[1]), len(sw[1])
340
+ if (x >= 70) or (m and d and (not y)) or (c > 3) then
341
+ sety( x + ((x >= 100 or c>3)and 0 or 1900) )
342
+ else
343
+ if m then setd(x) else m = x end
344
+ end
345
+ elseif sw("^(%a+)[/\\%s,-]?%s*") then --print("$Words")
346
+ x = sw[1]
347
+ if inlist(x, sl_months, 2, sw) then
348
+ if m and (not d) and (not y) then d, m = m, false end
349
+ setm(mod(sw[0],12)+1)
350
+ elseif inlist(x, sl_timezone, 2, sw) then
351
+ c = fix(sw[0]) -- ignore gmt and utc
352
+ if c ~= 0 then setz(c, x) end
353
+ elseif inlist(x, sl_weekdays, 2, sw) then
354
+ k = sw[0]
355
+ else
356
+ sw:back()
357
+ -- am pm bce ad ce bc
358
+ if sw ("^([bB])%s*(%.?)%s*[Cc]%s*(%2)%s*[Ee]%s*(%2)%s*") or sw ("^([bB])%s*(%.?)%s*[Cc]%s*(%2)%s*") then
359
+ e = e and error_dup() or -1
360
+ elseif sw ("^([aA])%s*(%.?)%s*[Dd]%s*(%2)%s*") or sw ("^([cC])%s*(%.?)%s*[Ee]%s*(%2)%s*") then
361
+ e = e and error_dup() or 1
362
+ elseif sw("^([PApa])%s*(%.?)%s*[Mm]?%s*(%2)%s*") then
363
+ x = lwr(sw[1]) -- there should be hour and it must be correct
364
+ if (not h) or (h > 12) or (h < 0) then return error_inv() end
365
+ if x == 'a' and h == 12 then h = 0 end -- am
366
+ if x == 'p' and h ~= 12 then h = h + 12 end -- pm
367
+ else error_syn() end
368
+ end
369
+ elseif not(sw("^([+-])(%d%d?):(%d%d)",setzc) or sw("^([+-])(%d+)",setzn) or sw("^[Zz]%s*$")) then -- sw{"([+-])",{"(%d%d?):(%d%d)","(%d+)"}}
370
+ error_syn("?")
371
+ end
372
+ sw("^%s*") until sw:finish()
373
+ --else print("$Iso(Date|Time|Zone)")
374
+ end
375
+ -- if date is given, it must be complete year, month & day
376
+ if (not y and not h) or ((m and not d) or (d and not m)) or ((m and w) or (m and j) or (j and w)) then return error_inv("!") end
377
+ -- fix month
378
+ if m then m = m - 1 end
379
+ -- fix year if we are on BCE
380
+ if e and e < 0 and y > 0 then y = 1 - y end
381
+ -- create date object
382
+ dn = (y and ((w and makedaynum_isoywd(y,w,u)) or (j and makedaynum(y, 0, j)) or makedaynum(y, m, d))) or DAYNUM_DEF
383
+ df = makedayfrc(h or 0, r or 0, s or 0, 0) + ((z or 0)*TICKSPERMIN)
384
+ --print("Zone",h,r,s,z,m,d,y,df)
385
+ return date_new(dn, df) -- no need to :normalize();
386
+ end
387
+ local function date_fromtable(v)
388
+ local y, m, d = fix(v.year), getmontharg(v.month), fix(v.day)
389
+ local h, r, s, t = tonumber(v.hour), tonumber(v.min), tonumber(v.sec), tonumber(v.ticks)
390
+ -- atleast there is time or complete date
391
+ if (y or m or d) and (not(y and m and d)) then return error("incomplete table") end
392
+ return (y or h or r or s or t) and date_new(y and makedaynum(y, m, d) or DAYNUM_DEF, makedayfrc(h or 0, r or 0, s or 0, t or 0))
393
+ end
394
+ local tmap = {
395
+ ['number'] = function(v) return date_epoch:copy():addseconds(v) end,
396
+ ['string'] = function(v) return date_parse(v) end,
397
+ ['boolean']= function(v) return date_fromtable(osdate(v and "!*t" or "*t")) end,
398
+ ['table'] = function(v) local ref = getmetatable(v) == dobj; return ref and v or date_fromtable(v), ref end
399
+ }
400
+ local function date_getdobj(v)
401
+ local o, r = (tmap[type(v)] or fnil)(v);
402
+ return (o and o:normalize() or error"invalid date time value"), r -- if r is true then o is a reference to a date obj
403
+ end
404
+ --#end -- not DATE_OBJECT_AFX
405
+ local function date_from(...)
406
+ local y, m, d = fix(arg[1]), getmontharg(arg[2]), fix(arg[3])
407
+ local h, r, s, t = tonumber(arg[4] or 0), tonumber(arg[5] or 0), tonumber(arg[6] or 0), tonumber(arg[7] or 0)
408
+ if y and m and d and h and r and s and t then
409
+ return date_new(makedaynum(y, m, d), makedayfrc(h, r, s, t)):normalize()
410
+ else
411
+ return date_error_arg()
412
+ end
413
+ end
414
+
415
+ --[[ THE DATE OBJECT METHODS ]]--
416
+ function dobj:normalize()
417
+ local dn, df = fix(self.daynum), self.dayfrc
418
+ self.daynum, self.dayfrc = dn + floor(df/TICKSPERDAY), mod(df, TICKSPERDAY)
419
+ return (dn >= DAYNUM_MIN and dn <= DAYNUM_MAX) and self or error("date beyond imposed limits:"..self)
420
+ end
421
+
422
+ function dobj:getdate() local y, m, d = breakdaynum(self.daynum) return y, m+1, d end
423
+ function dobj:gettime() return breakdayfrc(self.dayfrc) end
424
+
425
+ function dobj:getclockhour() local h = self:gethours() return h>12 and mod(h,12) or (h==0 and 12 or h) end
426
+
427
+ function dobj:getyearday() return yearday(self.daynum) + 1 end
428
+ function dobj:getweekday() return weekday(self.daynum) + 1 end -- in lua weekday is sunday = 1, monday = 2 ...
429
+
430
+ function dobj:getyear() local r,_,_ = breakdaynum(self.daynum) return r end
431
+ function dobj:getmonth() local _,r,_ = breakdaynum(self.daynum) return r+1 end-- in lua month is 1 base
432
+ function dobj:getday() local _,_,r = breakdaynum(self.daynum) return r end
433
+ function dobj:gethours() return mod(floor(self.dayfrc/TICKSPERHOUR),HOURPERDAY) end
434
+ function dobj:getminutes() return mod(floor(self.dayfrc/TICKSPERMIN), MINPERHOUR) end
435
+ function dobj:getseconds() return mod(floor(self.dayfrc/TICKSPERSEC ),SECPERMIN) end
436
+ function dobj:getfracsec() return mod(floor(self.dayfrc/TICKSPERSEC ),SECPERMIN)+(mod(self.dayfrc,TICKSPERSEC)/TICKSPERSEC) end
437
+ function dobj:getticks(u) local x = mod(self.dayfrc,TICKSPERSEC) return u and ((x*u)/TICKSPERSEC) or x end
438
+
439
+ function dobj:getweeknumber(wdb)
440
+ local wd, yd = weekday(self.daynum), yearday(self.daynum)
441
+ if wdb then
442
+ wdb = tonumber(wdb)
443
+ if wdb then
444
+ wd = mod(wd-(wdb-1),7)-- shift the week day base
445
+ else
446
+ return date_error_arg()
447
+ end
448
+ end
449
+ return (yd < wd and 0) or (floor(yd/7) + ((mod(yd, 7)>=wd) and 1 or 0))
450
+ end
451
+
452
+ function dobj:getisoweekday() return mod(weekday(self.daynum)-1,7)+1 end -- sunday = 7, monday = 1 ...
453
+ function dobj:getisoweeknumber() return (isowy(self.daynum)) end
454
+ function dobj:getisoyear() return isoy(self.daynum) end
455
+ function dobj:getisodate()
456
+ local w, y = isowy(self.daynum)
457
+ return y, w, self:getisoweekday()
458
+ end
459
+ function dobj:setisoyear(y, w, d)
460
+ local cy, cw, cd = self:getisodate()
461
+ if y then cy = fix(tonumber(y))end
462
+ if w then cw = fix(tonumber(w))end
463
+ if d then cd = fix(tonumber(d))end
464
+ if cy and cw and cd then
465
+ self.daynum = makedaynum_isoywd(cy, cw, cd)
466
+ return self:normalize()
467
+ else
468
+ return date_error_arg()
469
+ end
470
+ end
471
+
472
+ function dobj:setisoweekday(d) return self:setisoyear(nil, nil, d) end
473
+ function dobj:setisoweeknumber(w,d) return self:setisoyear(nil, w, d) end
474
+
475
+ function dobj:setyear(y, m, d)
476
+ local cy, cm, cd = breakdaynum(self.daynum)
477
+ if y then cy = fix(tonumber(y))end
478
+ if m then cm = getmontharg(m) end
479
+ if d then cd = fix(tonumber(d))end
480
+ if cy and cm and cd then
481
+ self.daynum = makedaynum(cy, cm, cd)
482
+ return self:normalize()
483
+ else
484
+ return date_error_arg()
485
+ end
486
+ end
487
+
488
+ function dobj:setmonth(m, d)return self:setyear(nil, m, d) end
489
+ function dobj:setday(d) return self:setyear(nil, nil, d) end
490
+
491
+ function dobj:sethours(h, m, s, t)
492
+ local ch,cm,cs,ck = breakdayfrc(self.dayfrc)
493
+ ch, cm, cs, ck = tonumber(h or ch), tonumber(m or cm), tonumber(s or cs), tonumber(t or ck)
494
+ if ch and cm and cs and ck then
495
+ self.dayfrc = makedayfrc(ch, cm, cs, ck)
496
+ return self:normalize()
497
+ else
498
+ return date_error_arg()
499
+ end
500
+ end
501
+
502
+ function dobj:setminutes(m,s,t) return self:sethours(nil, m, s, t) end
503
+ function dobj:setseconds(s, t) return self:sethours(nil, nil, s, t) end
504
+ function dobj:setticks(t) return self:sethours(nil, nil, nil, t) end
505
+
506
+ function dobj:spanticks() return (self.daynum*TICKSPERDAY + self.dayfrc) end
507
+ function dobj:spanseconds() return (self.daynum*TICKSPERDAY + self.dayfrc)/TICKSPERSEC end
508
+ function dobj:spanminutes() return (self.daynum*TICKSPERDAY + self.dayfrc)/TICKSPERMIN end
509
+ function dobj:spanhours() return (self.daynum*TICKSPERDAY + self.dayfrc)/TICKSPERHOUR end
510
+ function dobj:spandays() return (self.daynum*TICKSPERDAY + self.dayfrc)/TICKSPERDAY end
511
+
512
+ function dobj:addyears(y, m, d)
513
+ local cy, cm, cd = breakdaynum(self.daynum)
514
+ if y then y = fix(tonumber(y))else y = 0 end
515
+ if m then m = fix(tonumber(m))else m = 0 end
516
+ if d then d = fix(tonumber(d))else d = 0 end
517
+ if y and m and d then
518
+ self.daynum = makedaynum(cy+y, cm+m, cd+d)
519
+ return self:normalize()
520
+ else
521
+ return date_error_arg()
522
+ end
523
+ end
524
+
525
+ function dobj:addmonths(m, d)
526
+ return self:addyears(nil, m, d)
527
+ end
528
+
529
+ local function dobj_adddayfrc(self,n,pt,pd)
530
+ n = tonumber(n)
531
+ if n then
532
+ local x = floor(n/pd);
533
+ self.daynum = self.daynum + x;
534
+ self.dayfrc = self.dayfrc + (n-x*pd)*pt;
535
+ return self:normalize()
536
+ else
537
+ return date_error_arg()
538
+ end
539
+ end
540
+ function dobj:adddays(n) return dobj_adddayfrc(self,n,TICKSPERDAY,1) end
541
+ function dobj:addhours(n) return dobj_adddayfrc(self,n,TICKSPERHOUR,HOURPERDAY) end
542
+ function dobj:addminutes(n) return dobj_adddayfrc(self,n,TICKSPERMIN,MINPERDAY) end
543
+ function dobj:addseconds(n) return dobj_adddayfrc(self,n,TICKSPERSEC,SECPERDAY) end
544
+ function dobj:addticks(n) return dobj_adddayfrc(self,n,1,TICKSPERDAY) end
545
+ local tvspec = {
546
+ -- Abbreviated weekday name (Sun)
547
+ ['%a']=function(self) return sl_weekdays[weekday(self.daynum) + 7] end,
548
+ -- Full weekday name (Sunday)
549
+ ['%A']=function(self) return sl_weekdays[weekday(self.daynum)] end,
550
+ -- Abbreviated month name (Dec)
551
+ ['%b']=function(self) return sl_months[self:getmonth() - 1 + 12] end,
552
+ -- Full month name (December)
553
+ ['%B']=function(self) return sl_months[self:getmonth() - 1] end,
554
+ -- Year/100 (19, 20, 30)
555
+ ['%C']=function(self) return fmt("%.2d", fix(self:getyear()/100)) end,
556
+ -- The day of the month as a number (range 1 - 31)
557
+ ['%d']=function(self) return fmt("%.2d", self:getday()) end,
558
+ -- year for ISO 8601 week, from 00 (79)
559
+ ['%g']=function(self) return fmt("%.2d", mod(self:getisoyear() ,100)) end,
560
+ -- year for ISO 8601 week, from 0000 (1979)
561
+ ['%G']=function(self) return fmt("%.4d", self:getisoyear()) end,
562
+ -- same as %b
563
+ ['%h']=function(self) return self:fmt0("%b") end,
564
+ -- hour of the 24-hour day, from 00 (06)
565
+ ['%H']=function(self) return fmt("%.2d", self:gethours()) end,
566
+ -- The hour as a number using a 12-hour clock (01 - 12)
567
+ ['%I']=function(self) return fmt("%.2d", self:getclockhour()) end,
568
+ -- The day of the year as a number (001 - 366)
569
+ ['%j']=function(self) return fmt("%.3d", self:getyearday()) end,
570
+ -- Month of the year, from 01 to 12
571
+ ['%m']=function(self) return fmt("%.2d", self:getmonth()) end,
572
+ -- Minutes after the hour 55
573
+ ['%M']=function(self) return fmt("%.2d", self:getminutes())end,
574
+ -- AM/PM indicator (AM)
575
+ ['%p']=function(self) return sl_meridian[self:gethours() > 11 and 1 or -1] end, --AM/PM indicator (AM)
576
+ -- The second as a number (59, 20 , 01)
577
+ ['%S']=function(self) return fmt("%.2d", self:getseconds()) end,
578
+ -- ISO 8601 day of the week, to 7 for Sunday (7, 1)
579
+ ['%u']=function(self) return self:getisoweekday() end,
580
+ -- Sunday week of the year, from 00 (48)
581
+ ['%U']=function(self) return fmt("%.2d", self:getweeknumber()) end,
582
+ -- ISO 8601 week of the year, from 01 (48)
583
+ ['%V']=function(self) return fmt("%.2d", self:getisoweeknumber()) end,
584
+ -- The day of the week as a decimal, Sunday being 0
585
+ ['%w']=function(self) return self:getweekday() - 1 end,
586
+ -- Monday week of the year, from 00 (48)
587
+ ['%W']=function(self) return fmt("%.2d", self:getweeknumber(2)) end,
588
+ -- The year as a number without a century (range 00 to 99)
589
+ ['%y']=function(self) return fmt("%.2d", mod(self:getyear() ,100)) end,
590
+ -- Year with century (2000, 1914, 0325, 0001)
591
+ ['%Y']=function(self) return fmt("%.4d", self:getyear()) end,
592
+ -- Time zone offset, the date object is assumed local time (+1000, -0230)
593
+ ['%z']=function(self) local b = -self:getbias(); local x = abs(b); return fmt("%s%.4d", b < 0 and "-" or "+", fix(x/60)*100 + floor(mod(x,60))) end,
594
+ -- Time zone name, the date object is assumed local time
595
+ ['%Z']=function(self) return self:gettzname() end,
596
+ -- Misc --
597
+ -- Year, if year is in BCE, prints the BCE Year representation, otherwise result is similar to "%Y" (1 BCE, 40 BCE)
598
+ ['%\b']=function(self) local x = self:getyear() return fmt("%.4d%s", x>0 and x or (-x+1), x>0 and "" or " BCE") end,
599
+ -- Seconds including fraction (59.998, 01.123)
600
+ ['%\f']=function(self) local x = self:getfracsec() return fmt("%s%.9g",x >= 10 and "" or "0", x) end,
601
+ -- percent character %
602
+ ['%%']=function(self) return "%" end,
603
+ -- Group Spec --
604
+ -- 12-hour time, from 01:00:00 AM (06:55:15 AM); same as "%I:%M:%S %p"
605
+ ['%r']=function(self) return self:fmt0("%I:%M:%S %p") end,
606
+ -- hour:minute, from 01:00 (06:55); same as "%I:%M"
607
+ ['%R']=function(self) return self:fmt0("%I:%M") end,
608
+ -- 24-hour time, from 00:00:00 (06:55:15); same as "%H:%M:%S"
609
+ ['%T']=function(self) return self:fmt0("%H:%M:%S") end,
610
+ -- month/day/year from 01/01/00 (12/02/79); same as "%m/%d/%y"
611
+ ['%D']=function(self) return self:fmt0("%m/%d/%y") end,
612
+ -- year-month-day (1979-12-02); same as "%Y-%m-%d"
613
+ ['%F']=function(self) return self:fmt0("%Y-%m-%d") end,
614
+ -- The preferred date and time representation; same as "%x %X"
615
+ ['%c']=function(self) return self:fmt0("%x %X") end,
616
+ -- The preferred date representation, same as "%a %b %d %\b"
617
+ ['%x']=function(self) return self:fmt0("%a %b %d %\b") end,
618
+ -- The preferred time representation, same as "%H:%M:%\f"
619
+ ['%X']=function(self) return self:fmt0("%H:%M:%\f") end,
620
+ -- GroupSpec --
621
+ -- Iso format, same as "%Y-%m-%dT%T"
622
+ ['${iso}'] = function(self) return self:fmt0("%Y-%m-%dT%T") end,
623
+ -- http format, same as "%a, %d %b %Y %T GMT"
624
+ ['${http}'] = function(self) return self:fmt0("%a, %d %b %Y %T GMT") end,
625
+ -- ctime format, same as "%a %b %d %T GMT %Y"
626
+ ['${ctime}'] = function(self) return self:fmt0("%a %b %d %T GMT %Y") end,
627
+ -- RFC850 format, same as "%A, %d-%b-%y %T GMT"
628
+ ['${rfc850}'] = function(self) return self:fmt0("%A, %d-%b-%y %T GMT") end,
629
+ -- RFC1123 format, same as "%a, %d %b %Y %T GMT"
630
+ ['${rfc1123}'] = function(self) return self:fmt0("%a, %d %b %Y %T GMT") end,
631
+ -- asctime format, same as "%a %b %d %T %Y"
632
+ ['${asctime}'] = function(self) return self:fmt0("%a %b %d %T %Y") end,
633
+ }
634
+ function dobj:fmt0(str) return (gsub(str, "%%[%a%%\b\f]", function(x) local f = tvspec[x];return (f and f(self)) or x end)) end
635
+ function dobj:fmt(str)
636
+ str = str or self.fmtstr or fmtstr
637
+ return self:fmt0((gmatch(str, "${%w+}")) and (gsub(str, "${%w+}", function(x)local f=tvspec[x];return (f and f(self)) or x end)) or str)
638
+ end
639
+
640
+ function dobj.__lt(a,b) return (a.daynum == b.daynum) and (a.dayfrc < b.dayfrc) or (a.daynum < b.daynum) end
641
+ function dobj.__le(a, b)return (a.daynum == b.daynum) and (a.dayfrc <= b.dayfrc) or (a.daynum <= b.daynum) end
642
+ function dobj.__eq(a, b)return (a.daynum == b.daynum) and (a.dayfrc == b.dayfrc) end
643
+ function dobj.__sub(a,b)
644
+ local d1, d2 = date_getdobj(a), date_getdobj(b)
645
+ local d0 = d1 and d2 and date_new(d1.daynum - d2.daynum, d1.dayfrc - d2.dayfrc)
646
+ return d0 and d0:normalize()
647
+ end
648
+ function dobj.__add(a,b)
649
+ local d1, d2 = date_getdobj(a), date_getdobj(b)
650
+ local d0 = d1 and d2 and date_new(d1.daynum + d2.daynum, d1.dayfrc + d2.dayfrc)
651
+ return d0 and d0:normalize()
652
+ end
653
+ function dobj.__concat(a, b) return tostring(a) .. tostring(b) end
654
+ function dobj:__tostring() return self:fmt() end
655
+
656
+ function dobj:copy() return date_new(self.daynum, self.dayfrc) end
657
+
658
+ --[[ THE LOCAL DATE OBJECT METHODS ]]--
659
+ function dobj:tolocal()
660
+ local dn,df = self.daynum, self.dayfrc
661
+ local bias = getbiasutc2(self)
662
+ if bias then
663
+ -- utc = local + bias; local = utc - bias
664
+ self.daynum = dn
665
+ self.dayfrc = df - bias*TICKSPERSEC
666
+ return self:normalize()
667
+ else
668
+ return nil
669
+ end
670
+ end
671
+
672
+ function dobj:toutc()
673
+ local dn,df = self.daynum, self.dayfrc
674
+ local bias = getbiasloc2(dn, df)
675
+ if bias then
676
+ -- utc = local + bias;
677
+ self.daynum = dn
678
+ self.dayfrc = df + bias*TICKSPERSEC
679
+ return self:normalize()
680
+ else
681
+ return nil
682
+ end
683
+ end
684
+
685
+ function dobj:getbias() return (getbiasloc2(self.daynum, self.dayfrc))/SECPERMIN end
686
+
687
+ function dobj:gettzname()
688
+ local _, tvu, _ = getbiasloc2(self.daynum, self.dayfrc)
689
+ return tvu and osdate("%Z",tvu) or ""
690
+ end
691
+
692
+ --#if not DATE_OBJECT_AFX then
693
+ function date.time(h, r, s, t)
694
+ h, r, s, t = tonumber(h or 0), tonumber(r or 0), tonumber(s or 0), tonumber(t or 0)
695
+ if h and r and s and t then
696
+ return date_new(DAYNUM_DEF, makedayfrc(h, r, s, t))
697
+ else
698
+ return date_error_arg()
699
+ end
700
+ end
701
+
702
+ function date:__call(...)
703
+ local n = #arg
704
+ if n > 1 then return (date_from(unpack(arg)))
705
+ elseif n == 0 then return (date_getdobj(false))
706
+ else local o, r = date_getdobj(arg[1]); return r and o:copy() or o end
707
+ end
708
+
709
+ date.diff = dobj.__sub
710
+
711
+ function date.isleapyear(v)
712
+ local y = fix(v);
713
+ if not y then
714
+ y = date_getdobj(v)
715
+ y = y and y:getyear()
716
+ end
717
+ return isleapyear(y+0)
718
+ end
719
+
720
+ function date.epoch() return date_epoch:copy() end
721
+
722
+ function date.isodate(y,w,d) return date_new(makedaynum_isoywd(y + 0, w and (w+0) or 1, d and (d+0) or 1), 0) end
723
+
724
+ -- Internal functions
725
+ function date.fmt(str) if str then fmtstr = str end; return fmtstr end
726
+ function date.daynummin(n) DAYNUM_MIN = (n and n < DAYNUM_MAX) and n or DAYNUM_MIN return n and DAYNUM_MIN or date_new(DAYNUM_MIN, 0):normalize()end
727
+ function date.daynummax(n) DAYNUM_MAX = (n and n > DAYNUM_MIN) and n or DAYNUM_MAX return n and DAYNUM_MAX or date_new(DAYNUM_MAX, 0):normalize()end
728
+ function date.ticks(t) if t then setticks(t) end return TICKSPERSEC end
729
+ --#end -- not DATE_OBJECT_AFX
730
+
731
+ local tm = osdate("!*t", 0);
732
+ if tm then
733
+ date_epoch = date_new(makedaynum(tm.year, tm.month - 1, tm.day), makedayfrc(tm.hour, tm.min, tm.sec, 0))
734
+ -- the distance from our epoch to os epoch in daynum
735
+ DATE_EPOCH = date_epoch and date_epoch:spandays()
736
+ else -- error will be raise only if called!
737
+ date_epoch = setmetatable({},{__index = function() error("failed to get the epoch date") end})
738
+ end
739
+
740
+ --#if not DATE_OBJECT_AFX then
741
+ return date
742
+ --#else
743
+ --$return date_from
744
+ --#end
745
+