Microsoft Windows SYSTEMTIME structure: JavaScript 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.

Usage

Runtime library

All parsing code for JavaScript generated by Kaitai Struct depends on the JavaScript runtime library. You have to install it before you can parse data.

The JavaScript runtime library is available at npm:

npm install kaitai-struct

Code

See the usage examples in the JavaScript notes.

Parse structure from an ArrayBuffer:

var arrayBuffer = ...;
var data = new WindowsSystemtime(new KaitaiStream(arrayBuffer));

After that, one can get various attributes from the structure by accessing fields or properties like:

data.year // => Year

JavaScript source code to parse Microsoft Windows SYSTEMTIME structure

WindowsSystemtime.js

// This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild

(function (root, factory) {
  if (typeof define === 'function' && define.amd) {
    define(['kaitai-struct/KaitaiStream'], factory);
  } else if (typeof module === 'object' && module.exports) {
    module.exports = factory(require('kaitai-struct/KaitaiStream'));
  } else {
    root.WindowsSystemtime = factory(root.KaitaiStream);
  }
}(this, function (KaitaiStream) {
/**
 * Microsoft Windows SYSTEMTIME structure, stores individual components
 * of date and time as individual fields, up to millisecond precision.
 * @see {@link https://docs.microsoft.com/en-us/windows/win32/api/minwinbase/ns-minwinbase-systemtime|Source}
 */

var WindowsSystemtime = (function() {
  function WindowsSystemtime(_io, _parent, _root) {
    this._io = _io;
    this._parent = _parent;
    this._root = _root || this;

    this._read();
  }
  WindowsSystemtime.prototype._read = function() {
    this.year = this._io.readU2le();
    this.month = this._io.readU2le();
    this.dow = this._io.readU2le();
    this.day = this._io.readU2le();
    this.hour = this._io.readU2le();
    this.min = this._io.readU2le();
    this.sec = this._io.readU2le();
    this.msec = this._io.readU2le();
  }

  /**
   * Year
   */

  /**
   * Month (January = 1)
   */

  /**
   * Day of week (Sun = 0)
   */

  /**
   * Day of month
   */

  /**
   * Hours
   */

  /**
   * Minutes
   */

  /**
   * Seconds
   */

  /**
   * Milliseconds
   */

  return WindowsSystemtime;
})();
return WindowsSystemtime;
}));