https://github.com/frobware/haproxytime
Parse time durations with support for days
https://github.com/frobware/haproxytime
duration-parsing go haproxy time
Last synced: 10 months ago
JSON representation
Parse time durations with support for days
- Host: GitHub
- URL: https://github.com/frobware/haproxytime
- Owner: frobware
- License: mit
- Created: 2023-05-24T07:40:22.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2024-04-04T11:22:25.000Z (about 2 years ago)
- Last Synced: 2025-06-20T19:37:00.031Z (10 months ago)
- Topics: duration-parsing, go, haproxy, time
- Language: Go
- Homepage:
- Size: 79.1 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# haproxytime
`haproxytime` is a command-line utility designed to facilitate the
conversion of human-readable time durations into a format precisely
represented in milliseconds, tailored specifically for HAProxy
configurations.
This tool is useful for developers and administrators who work with
HAProxy, providing a straightforward mechanism to ensure that timeout
configurations are accurately specified in a format that HAProxy can
understand. Whether you're inputting durations directly or piping them
from standard input, `haproxytime` streamlines the process of dealing
with time durations, supporting a wide range of units from days to
microseconds. With features to display durations in both machine- and
human-readable formats, as well as the ability to print the maximum
HAProxy timeout value, `haproxytime` minimises the risk of
configuration errors in your HAProxy setup.
## Install
To install without versioning information:
```sh
$ go install github.com/frobware/haproxytime@latest
```
To install with versioning information:
```sh
$ go install -ldflags "-X 'main.buildVersion=$(git describe --tags --abbrev=8 --dirty --always --long)'" github.com/frobware/haproxytime@latest
```
## Usage
```console
haproxytime - Convert human-readable time duration to millisecond format
General Usage:
haproxytime [-help] [-v]
haproxytime [-h] [-m] []
Usage:
-help Show usage information
-v Show version information
-h Print duration value in a human-readable format
-m Print the maximum HAProxy timeout value
: value to convert. If omitted, will read from stdin.
The flags [-help] and [-v] are mutually exclusive with any other
options or duration input.
Available units for time durations:
d days
h: hours
m: minutes
s: seconds
ms: milliseconds
us: microseconds
A duration value without a unit defaults to milliseconds.
Examples:
haproxytime -m -> Print the maximum HAProxy duration.
haproxytime 2h30m5s -> Convert duration to milliseconds.
haproxytime -h 4500000 -> Convert 4500000ms to a human-readable format.
echo 150s | haproxytime -> Convert 150 seconds to milliseconds.
```
## Build
```sh
$ make
$ make install
```