https://github.com/neomantra/ymdflag
YMDFlag implements a Golang flag.Value interface for YYYYMMDD-specified dates, facilitating CLI argument handling of dates like -start-date=20210101
https://github.com/neomantra/ymdflag
flag golang ymd
Last synced: 4 months ago
JSON representation
YMDFlag implements a Golang flag.Value interface for YYYYMMDD-specified dates, facilitating CLI argument handling of dates like -start-date=20210101
- Host: GitHub
- URL: https://github.com/neomantra/ymdflag
- Owner: neomantra
- License: mit
- Created: 2023-07-05T18:53:25.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-11-28T05:33:56.000Z (over 2 years ago)
- Last Synced: 2025-10-30T06:29:08.146Z (8 months ago)
- Topics: flag, golang, ymd
- Language: Go
- Homepage:
- Size: 26.4 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# ymdflag #
[](https://github.com/neomantra/ymdflag/actions/workflows/unit_tests.yaml)
[](https://coveralls.io/github/neomantra/ymdflag?branch=main)
[](https://github.com/neomantra/ymdflag/actions/workflows/golangci-lint.yaml)
[](https://github.com/neomantra/ymdflag/actions/workflows/codeql-analysis.yml)
[](http://goreportcard.com/report/neomantra/ymdflag)
[](https://pkg.go.dev/github.com/neomantra/ymdflag)
[`YMDFlag`](https://github.com/neomantra/ymdflag) implements a Golang [`flag.Value`](https://pkg.go.dev/flag#Value) interface for `YYYYMMDD`-specified dates. This facilitiates command-line argument handling of date parameters such `-start-date=20210101`.
## Documentation ##
```
go get github.com/neomantra/ymdflag
```
https://pkg.go.dev/github.com/neomantra/ymdflag
## Examples ##
There are examples in the [`examples/` directory](./examples). Here's a quick sketch:
```go
package main
import (
"github.com/neomantra/ymdflag"
"github.com/spf13/pflag"
)
func main() {
var ymd ymdflag.YMDFlag
pflag.VarP(&ymd, "date", "d", "YYYYMMDD date; defaults to today in local time")
pflag.Parse()
println("time of date:", ymd.AsTime().String())
}
```
----
## Credits and License
Copyright (c) 2022-2023 Neomantra BV. Authored by Evan Wies.
Released under the [MIT License](https://en.wikipedia.org/wiki/MIT_License), see [LICENSE.txt](./LICENSE.txt).