org.rrd4j.core.timespec

## Class TimeParser

- java.lang.Object
- - org.rrd4j.core.timespec.TimeParser

-     public class TimeParser
      extends Object

  Parser for at-style time specifications used in RRDTool commands.

  This class parses human-readable time specifications in the format described in detail on the rrdfetch man page. It is primarily a Java port of Tobi Oetiker's parsetime.c code, adapted for Java conventions.

  Supported time specification formats include:
  - Absolute times: "Jan 1 2023", "12:30", "2023/01/01 12:30:45"
  - Relative times: "now-2hours", "tomorrow", "noon yesterday"
  - Natural language: "midnight", "teatime", "start of week"
  - Time ranges: "start+1week", "end-2days"

  Special parsing rules:
  - Two-digit years before 38 are interpreted as post-2000
  - Ambiguous "m" token resolved based on context (months vs minutes)
  - Supports both 12-hour (AM/PM) and 24-hour time formats
  - Multiple date separators accepted: "/", ".", "-"

  The parser uses a two-phase approach:
  1. Lexical scanning (`TimeScanner`) breaks input into tokens
  2. Grammar parsing interprets tokens according to at-style syntax rules

  Example usage:

       TimeParser parser = new TimeParser("now-1day+2hours");
       TimeSpec spec = parser.parse();
       long timestamp = spec.getTimestamp();

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `(package private) int` | `op`
    `(package private) int` | `prev_multiplier`
    `(package private) TimeScanner` | `scanner`
    `(package private) TimeSpec` | `spec`
    `(package private) TimeToken` | `token`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `TimeParser(String dateString)` Constructs TimeParser instance from the given input string.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `TimeSpec` | `parse()` Parses the input string specified in the constructor.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### op

          int op

    - #### prev_multiplier

          int prev_multiplier

    - #### scanner

          final TimeScanner scanner

    - #### spec

          final TimeSpec spec

    - #### token

          TimeToken token

  - ### Constructor Detail

    - #### TimeParser

          public TimeParser(String dateString)

      Constructs TimeParser instance from the given input string.
      Parameters:
        `dateString` - at-style time specification (read rrdfetch man page for the complete explanation)

  - ### Method Detail

    - #### parse

          public TimeSpec parse()

      Parses the input string specified in the constructor.
      Returns:
        Object representing parsed date/time.