Skip to content

Commit

Permalink
doc(examples): add naive examples
Browse files Browse the repository at this point in the history
  • Loading branch information
sonirico committed Mar 15, 2020
1 parent da2cdbc commit 6c5c9ea
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions examples/naive.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package main

import (
"fmt"
"github.com/sonirico/datetoken.go"
)

func main() {
tokens := []string{
"now/s",
"now/m",
"now/h",
"now/d",
"now/w",
"now/bw",
"now/M",
"now/Y",
}
fmt.Println("Snap to start of units")
for _, token := range tokens {
date, _ := datetoken.EvalNaive(token)
fmt.Printf("\n{token: %s, time: %s}", token, date)
}
fmt.Printf("\n")
fmt.Println("Snap to end of units")
tokens = []string{
"now@s",
"now@m",
"now@h",
"now@d",
"now@w",
"now@bw",
"now@M",
"now@Y",
}
for _, token := range tokens {
date, _ := datetoken.EvalNaive(token)
fmt.Printf("\n{token: %s, time: %s}", token, date)
}
fmt.Printf("\n")
}

0 comments on commit 6c5c9ea

Please sign in to comment.