Microsoft Windows SYSTEMTIME structure: Lua parsing library

Microsoft Windows SYSTEMTIME structure, stores individual components of date and time as individual fields, up to millisecond precision.

KS implementation details

License: CC0-1.0

This page hosts a formal specification of Microsoft Windows SYSTEMTIME structure using Kaitai Struct. This specification can be automatically translated into a variety of programming languages to get a parsing library.

Lua source code to parse Microsoft Windows SYSTEMTIME structure

windows_systemtime.lua

-- This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild
--
-- This file is compatible with Lua 5.3

local class = require("class")
require("kaitaistruct")

-- 
-- Microsoft Windows SYSTEMTIME structure, stores individual components
-- of date and time as individual fields, up to millisecond precision.
-- See also: Source (https://docs.microsoft.com/en-us/windows/win32/api/minwinbase/ns-minwinbase-systemtime)
WindowsSystemtime = class.class(KaitaiStruct)

function WindowsSystemtime:_init(io, parent, root)
  KaitaiStruct._init(self, io)
  self._parent = parent
  self._root = root or self
  self:_read()
end

function WindowsSystemtime:_read()
  self.year = self._io:read_u2le()
  self.month = self._io:read_u2le()
  self.dow = self._io:read_u2le()
  self.day = self._io:read_u2le()
  self.hour = self._io:read_u2le()
  self.min = self._io:read_u2le()
  self.sec = self._io:read_u2le()
  self.msec = self._io:read_u2le()
end

-- 
-- Year.
-- 
-- Month (January = 1).
-- 
-- Day of week (Sun = 0).
-- 
-- Day of month.
-- 
-- Hours.
-- 
-- Minutes.
-- 
-- Seconds.
-- 
-- Milliseconds.