Skip to content

Commit

Permalink
until -> before
Browse files Browse the repository at this point in the history
  • Loading branch information
khw7096 committed Apr 1, 2019
1 parent c1c81eb commit 9c77f07
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,25 @@ From 2019-03-01 to 2019-03-31 : 80h29m10s
$ git hours -help
```

### since, until date
### since, before date
기본적으로 아무값도 넣지 않으면 지난달의 시작일, 마지막일로 설정됩니다.
원한다면 사용자가 아래처럼 시작일, 마지막일을 설정할 수 있습니다.

```
$ git hours -since 2019-02-01 -until 2019-02-28
$ git hours -since 2019-02-01 -before 2019-02-28
```

타임존값을 입력해야하는 상황이 필요할때는 아래처럼 입력할 수 있습니다.
```
$ git hours -since "2019-03-29 13:55:33 +0800"
```

기본적으로 before값에 날짜만 넣으면 그 날짜의 시작시간이 기준이됩니다.
정확한 견적이 필요할 때는 아래처럼 해당 날짜의 시간, 타임존까지 모두 입력해주세요.
```
$ git hours -since "2019-03-01 00:00:00 +0900" -before "2019-03-31 23:59:59 +0900"
```

### set author
```
$ git hours -author name
Expand Down
16 changes: 8 additions & 8 deletions git-hours.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ func init() {
}

func main() {
since, until := beforeMonth()
since, before := beforeMonth()
sincePtr := flag.String("since", since, "since(after) date")
untilPtr := flag.String("until", until, "until(before) date")
beforePtr := flag.String("before", before, "before date")
authorPtr := flag.String("author", "", "author name") // git option : --author="\(Adam\)\|\(Jon\)"
debugPtr := flag.Bool("debug", false, "debug mode")
helpPtr := flag.Bool("help", false, "print help")
Expand All @@ -85,7 +85,7 @@ func main() {
`--pretty=format:%ad %an %s`,
fmt.Sprintf(`--author=%s`, author),
fmt.Sprintf(`--since="%s"`, *sincePtr),
fmt.Sprintf(`--until="%s"`, *untilPtr),
fmt.Sprintf(`--before="%s"`, *beforePtr),
)
var stdout bytes.Buffer
var stderr bytes.Buffer
Expand All @@ -106,11 +106,11 @@ func main() {
os.Exit(1)
}
if stdout.String() == "" {
fmt.Printf("From %s to %s : %s\n", *sincePtr, *untilPtr, total)
fmt.Printf("From %s to %s : %s\n", *sincePtr, *beforePtr, total)
os.Exit(0)
}

var before time.Time
var beforeCommitTime time.Time
for n, l := range strings.Split(stdout.String(), "\n") {
getTime := findISO8601.FindString(l)
if getTime == "" {
Expand All @@ -124,7 +124,7 @@ func main() {
if err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
}
elapsed := t.Sub(before)
elapsed := t.Sub(beforeCommitTime)
if *debugPtr {
if n != 0 {
fmt.Println(elapsed, ">")
Expand All @@ -140,7 +140,7 @@ func main() {
} else {
total += h
}
before = t
beforeCommitTime = t
}
fmt.Printf("From %s to %s : %s\n", *sincePtr, *untilPtr, total)
fmt.Printf("From %s to %s : %s\n", *sincePtr, *beforePtr, total)
}

0 comments on commit 9c77f07

Please sign in to comment.