Skip to content
/ yyflag Public

Package yyflag implement flag.Getter interface for time.Time values, allowing date/time to be entered as flags at command line

License

Notifications You must be signed in to change notification settings

djadala/yyflag

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

yyflag

Package yyflag implement flag.Getter interface for time.Time values, allowing date/time to be entered as flags at command line. yyflag allow all incomplete formats of package djadala/yy to be used.

yyflag recognize following formats: ['date'][#'time'][@'zone'] or ['date'][T'time'][@'zone']

'date' is one of:

  • +ddd relative days
  • -ddd relative days
  • jjj julian year day
  • y-jjj year 1 digit + julian year day
  • yy-jjj year 2 digit + julian year day
  • yyy-jjj year 3 digit + julian year day
  • yyyy-jjj year + julian year day
  • dd day
  • mm-dd month + day
  • y-mm-dd year 1 digit + month + day
  • yy-mm-dd year 2 digit + month + day
  • yyy-mm-dd year 3 digit + month + day
  • yyyy-mm-dd year + month + day
  • mm month
  • y-mm year 1 digit + month
  • yy-mm year 2 digit + month
  • yyy-mm year 3 digit + month
  • yyyy-mm year + month
  • y year 1 digit
  • yy year 2 digit
  • yyy year 3 digit
  • yyyy year

'time' is one of:

  • hh
  • hh:mm
  • hh:mm:ss
  • hh:mm:ss.d+

'timezone' is one of:

  • +/-hh:mm
  • +/-hhmm
  • timezoneName
  • z UTC
  • l Local

GoDoc

example:

package main

import (
	"flag"
	"fmt"
	"time"

	"github.com/djadala/yyflag"
)

func main() {
	deft := time.Now().UTC().Truncate(24 * time.Hour)

	from := yyflag.New(deft)
	to := yyflag.New(deft.AddDate(0, 0, 1))

	flag.Var(&from, "f", "from date")
	flag.Var(&to, "t", "to date")

	flag.Parse()

	fmt.Println(from.Time())
	fmt.Println(to.Time())
}

About

Package yyflag implement flag.Getter interface for time.Time values, allowing date/time to be entered as flags at command line

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages