-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[dateutils] adding func BeforeOrEqual and AfterOrEqual (#23)
Co-authored-by: Vincent Hoen <vincent.hoen@ext.groupepvcp.com>
- Loading branch information
Showing
5 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Ceil | ||
|
||
`func AfterOrEqual(milestone time.Time, date time.Time) bool` | ||
|
||
AfterOrEqual - returns true if a date is equal or after to another date | ||
|
||
```go | ||
package main | ||
|
||
import ( | ||
"github.com/Goldziher/go-utils/dateutils" | ||
"time" | ||
) | ||
|
||
func main() { | ||
milestone, _ := time.Parse("2006-01-02", "2023-01-01") | ||
|
||
dBefore, _ := time.Parse("2006-01-02", "2022-12-31") | ||
dEqual, _ := time.Parse("2006-01-02", "2023-01-01") | ||
dAfter, _ := time.Parse("2006-01-02", "2023-01-31") | ||
|
||
dateutils.AfterOrEqual(milestone, dBefore) // false | ||
dateutils.AfterOrEqual(milestone, dEqual) // true | ||
dateutils.AfterOrEqual(milestone, dAfter) // true | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Ceil | ||
|
||
`func BeforeOrEqual(milestone time.Time, date time.Time) bool` | ||
|
||
BeforeOrEqual - returns true if a date is before or equal to another date | ||
|
||
```go | ||
package main | ||
|
||
import ( | ||
"github.com/Goldziher/go-utils/dateutils" | ||
"time" | ||
) | ||
|
||
func main() { | ||
milestone, _ := time.Parse("2006-01-02", "2023-01-01") | ||
|
||
dBefore, _ := time.Parse("2006-01-02", "2022-12-31") | ||
dEqual, _ := time.Parse("2006-01-02", "2023-01-01") | ||
dAfter, _ := time.Parse("2006-01-02", "2023-01-31") | ||
|
||
dateutils.BeforeOrEqual(milestone, dBefore) // true | ||
dateutils.BeforeOrEqual(milestone, dEqual) // true | ||
dateutils.BeforeOrEqual(milestone, dAfter) // false | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters