Skip to content

Commit

Permalink
wip: Adding diary format
Browse files Browse the repository at this point in the history
  • Loading branch information
Jelloeater committed Sep 19, 2024
1 parent 2724187 commit f1683fa
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var ( // Create by GoRelease at compile time
//date = "unknown"
)

func writeDate(format string, timezone string, ntpServer string) {
func writeDate(format string, timezone string, ntpServer string, diaryFormat bool) {

if os.Getenv("STAMPY_TZ") != "" {
timezone = os.Getenv("STAMPY_TZ")
Expand All @@ -27,6 +27,9 @@ func writeDate(format string, timezone string, ntpServer string) {
if os.Getenv("STAMPY_NTP") != "" {
ntpServer = os.Getenv("STAMPY_NTP")
}
if diaryFormat {
format = "1/2/2006 15:04"
}

loc, e := time.LoadLocation(timezone)
if e != nil {
Expand Down Expand Up @@ -57,13 +60,18 @@ func mainCliApp() error {
Name: "stampy",
Usage: "Copy formatted timestamp to system clipboard",
Args: true,
Version: "v" + version + " build " + commit,
Version: "v" + version + "+" + commit,
Flags: []cli.Flag{
&cli.StringFlag{
Name: "format",
Value: "2006-01-02T15:04:05Z07:00",
Usage: "Timestamp format",
},
&cli.BoolFlag{
Name: "diary",
Value: false,
Usage: "Diary format",
},
&cli.StringFlag{
Name: "timezone",
Value: "UTC",
Expand All @@ -83,7 +91,13 @@ func mainCliApp() error {
format := c.String("format")
timezone := c.String("timezone")
ntpServer := c.String("ntp_server")
writeDate(format, timezone, ntpServer)
diaryFormat := c.Bool("diary")
writeDate(
format,
timezone,
ntpServer,
diaryFormat,
)

return nil
},
Expand Down

0 comments on commit f1683fa

Please sign in to comment.