Skip to content

Commit b632fc7

Browse files
committed
change readme
1 parent b166343 commit b632fc7

File tree

1 file changed

+12
-25
lines changed

1 file changed

+12
-25
lines changed

README.md

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@
44

55
_Go implementation of systemd time (`man systemd.time`)_
66

7-
In command line applications, it is convenient to use the notation since `-1day`, or in `5 hours`. This package takes that string (using systemd time specs) and converts it into `time.Duration`. There is also a helper function that can take the raw string time adjustment and a `time.Time` (or `nil` for `time.Now()`) object and apply the adjustment to immutably. See [below for usage](#usage).
8-
9-
## Installation
10-
11-
You can use `dep` to install this vendor dependency, or `go get github.com/trstringer/go-systemd-time/systemdtime`.
7+
In command line applications, it is convenient to use the notation since `-1day`, or in `5 hours`. This package takes that string (using systemd time specs) and converts it into `time.Duration`. There is also a helper function that can take the raw string time adjustment and a `time.Time` (or `nil` for `time.Now()`) object and apply the adjustment to immutably. See below for usage.
128

139
## Usage
1410

@@ -20,39 +16,30 @@ import (
2016
"os"
2117
"time"
2218

23-
"github.com/trstringer/go-systemd-time/systemdtime"
19+
"github.com/trstringer/go-systemd-time/pkg/systemdtime"
2420
)
2521

2622
func main() {
2723
now := time.Now()
28-
fmt.Printf("Current date/time: %s\n", now)
24+
timeFormat := "3:04 PM on January 2, 2006"
2925

30-
twoDaysThreeHoursAgo, err := systemdtime.AdjustTime(&now, "-2 days 3 hr")
31-
if err != nil {
32-
fmt.Printf("Error converting: %v\n", err)
33-
os.Exit(1)
34-
}
35-
fmt.Printf("Two days and three hours ago: %s\n", twoDaysThreeHoursAgo)
26+
fmt.Printf("Now is %s\n", now.Format(timeFormat))
3627

37-
eighteenDaysTwelveMinutesFromNow, err := systemdtime.AdjustTime(&now, "18d12min")
28+
adjustedTime, err := systemdtime.AdjustTime(&now, "2d")
3829
if err != nil {
39-
fmt.Printf("Error converting: %v\n", err)
30+
fmt.Printf("error adjusting time: %v\n", err)
4031
os.Exit(1)
4132
}
42-
fmt.Printf("Eighteen days and twelve minutes from now: %s\n", eighteenDaysTwelveMinutesFromNow)
33+
fmt.Printf("Adjusted is %s\n", adjustedTime.Format(timeFormat))
34+
/*
35+
Now is 8:38 PM on September 30, 2020
36+
Adjusted is 8:38 PM on October 2, 2020
37+
*/
4338
}
4439
```
4540

46-
Output from the above sample...
47-
48-
```
49-
Current date/time: 2018-04-28 10:14:10.545534601 -0400 EDT m=+0.000220259
50-
Two days and three hours ago: 2018-04-26 07:14:10.545534601 -0400 EDT m=-183599.999779741
51-
Eighteen days and twelve minutes from now: 2018-05-16 10:26:10.545534601 -0400 EDT m=+1555920.000220259
52-
```
53-
5441
## Bug reports and running tests
5542

5643
If a bug is found, please write a failing test to uncover the bug.
5744

58-
To run tests, navigate to the root directory run `go test ./test/`.
45+
To run tests, navigate to the root directory and run `go test -v ./...`.

0 commit comments

Comments
 (0)