Skip to content

Commit 750ed95

Browse files
author
noah
committed
Add comments for functions
1 parent a8bbaab commit 750ed95

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,4 @@ Hyphens define ranges. For example, 2000-2010 indicates every year between 2000
5454

5555
## Details
5656

57-
* At this moment, the package supports only **UTC** timezone.
5857
* The return value of `Next` and `Prev` is zero if the pattern doesn't match in five years.

parser.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ var (
5656
}
5757
)
5858

59+
// MustParse returns the same result as Parse but it panic
60+
// when something is wrong.
5961
func MustParseInLocation(expr string, locName string) *Schedule {
6062
loc, err := time.LoadLocation(locName)
6163
if err != nil {
@@ -71,6 +73,10 @@ func MustParseInLocation(expr string, locName string) *Schedule {
7173
return schdule
7274
}
7375

76+
// ParseInLocation parse the expression in the location and
77+
// returns a new schedule representing the given spec.
78+
// It returns an error when loading the location is failed or
79+
// the syntax of the expression is wrong.
7480
func ParseInLocation(expr string, locName string) (*Schedule, error) {
7581
loc, err := time.LoadLocation(locName)
7682
if err != nil {
@@ -86,6 +92,8 @@ func ParseInLocation(expr string, locName string) (*Schedule, error) {
8692
return schdule, nil
8793
}
8894

95+
// MustParse returns the same result as Parse but it panic
96+
// when the syntax of expression is wrong.
8997
func MustParse(expr string) *Schedule {
9098
s, err := Parse(expr)
9199
if err != nil {
@@ -95,6 +103,9 @@ func MustParse(expr string) *Schedule {
95103
return s
96104
}
97105

106+
// Parse parses the expression and returns a new schedule representing the given spec.
107+
// And the default location of a schedule is "UTC".
108+
// It returns an error when the syntax of expression is wrong.
98109
func Parse(expr string) (*Schedule, error) {
99110
err := verifyExpr(expr)
100111
if err != nil {

schedule.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ type (
1212
}
1313
)
1414

15+
// Next returns the next time matched with the expression.
1516
func (s *Schedule) Next(t time.Time) time.Time {
1617
loc := time.UTC
1718
if s.Location != nil {
@@ -96,6 +97,7 @@ L:
9697
return t.In(origLoc)
9798
}
9899

100+
// Next returns the previous time matched with the expression.
99101
func (s *Schedule) Prev(t time.Time) time.Time {
100102
loc := time.UTC
101103
if s.Location != nil {

0 commit comments

Comments
 (0)