Skip to content

Commit

Permalink
Merge pull request #7 from goark:add-method
Browse files Browse the repository at this point in the history
Add methods in DateJp
  • Loading branch information
spiegel-im-spiegel committed Apr 17, 2022
2 parents 0b6eefb + 3c5c761 commit 8c25bd2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
12 changes: 11 additions & 1 deletion date.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,17 @@ func (t DateJp) After(dt DateJp) bool {
return !t.Equal(dt) && t.Time.After(dt.Time)
}

/* Copyright 2020 Spiegel
//AddDate method adds years/months/days and returns new Date instance.
func (t DateJp) AddDate(years int, months int, days int) DateJp {
return NewDate(t.Time.AddDate(years, months, days))
}

//AddDay method adds n days and returns new Date instance.
func (t DateJp) AddDay(days int) DateJp {
return t.AddDate(0, 0, days)
}

/* Copyright 2020-2022 Spiegel
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
5 changes: 4 additions & 1 deletion date_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,12 @@ func TestEqual(t *testing.T) {
if dt1.After(dt2) {
t.Error("DateJp.After() is true, want false.")
}
if !dt1.AddDay(1).Equal(dt2) {
t.Error("DateJp.Equal() is false, want true.")
}
}

/* Copyright 2020 Spiegel
/* Copyright 2020-2022 Spiegel
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down

0 comments on commit 8c25bd2

Please sign in to comment.