DWS Packages
    Preparing search index...

    Function parseHumanTime

    • Converts a human-readable time expression to a numeric value in the specified unit

      Parameters

      • timeExpression: string

        A string representing a time period (e.g., "2 hours", "30 minutes ago", "+1 day")

      • unit: TimeUnit = 'seconds'

        The unit to return the result in (default: "seconds")

      Returns number

      The time period in the requested unit (negative for past times)

      (Exception) - If the time expression is invalid or contains an unknown unit

      parseHumanTime("2 hours")           // Returns 7200 (seconds)
      parseHumanTime("30 mins ago") // Returns -1800 (seconds)
      parseHumanTime("+1 day", "hours") // Returns 24
      parseHumanTime("1 hour", "ms") // Returns 3600000