YMDFlag
implements a Golang flag.Value
interface for YYYYMMDD
-specified dates. This facilitiates command-line argument handling of date parameters such -start-date=20210101
.
go get github.com/neomantra/ymdflag
https://pkg.go.dev/github.com/neomantra/ymdflag
There are examples in the examples/
directory. Here's a quick sketch:
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())
}
Copyright (c) 2022-2023 Neomantra BV. Authored by Evan Wies.
Released under the MIT License, see LICENSE.txt.