Skip to content

Commit

Permalink
add handy time format & use DateOnly as default
Browse files Browse the repository at this point in the history
  • Loading branch information
Druggo Yang committed Jan 7, 2025
1 parent 077c097 commit 5832c97
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ The exporter expects either a YAML or JSON file with a single key, `deadlines`,
* type: string
* `deadline-time-format` - [golang time format string](https://golang.org/pkg/time/#Time.Format) (Example golang time format [constants](https://golang.org/pkg/time/#pkg-constants))
* type: string
* default: RFC3339
* default: DateOnly
* **Warning - exporter does not handle format strings without year, month, day, and tz info**
* `threshold` - threshold quantity
* type: int
* default: days
* default: 7
* `threshold-type` - threshold type from one of: `years`, `months`, `days`, `hours`, `minutes`, `seconds`
* type: string
* default: RFC3339
* default: days

### Exported Prometheus Metric Reference:
* Name: `countdown_timers`
Expand Down
9 changes: 7 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ var timeFormatConstants = map[string]string{
"RFC1123Z": "Mon, 02 Jan 2006 15:04:05 -0700", // RFC1123 with numeric zone
"RFC3339": "2006-01-02T15:04:05Z07:00",
"RFC3339Nano": "2006-01-02T15:04:05.999999999Z07:00",
// Handy time format.
"Stamp": "Jan _2 15:04:05",
"DateTime": "2006-01-02 15:04:05",
"DateOnly": "2006-01-02",
"TimeOnly": "15:04:05",
}

var (
Expand All @@ -48,8 +53,8 @@ var (
)

var (
DefaultDeadlineTimeFormat = "RFC3339"
DefaultThreshold = 60
DefaultDeadlineTimeFormat = "DateOnly"
DefaultThreshold = 7
DefaultThresholdType = "days"
)

Expand Down

0 comments on commit 5832c97

Please sign in to comment.