Rename ToTime->JDateToTime
This commit is contained in:
parent
001ac47315
commit
d862f6c35d
|
@ -97,7 +97,7 @@ func New(year int, month time.Month, day int) Date {
|
||||||
|
|
||||||
// The algorithm, in large part: follows this article:
|
// The algorithm, in large part: follows this article:
|
||||||
// https://en.wikipedia.org/wiki/Conversion_between_Julian_and_Gregorian_calendars
|
// https://en.wikipedia.org/wiki/Conversion_between_Julian_and_Gregorian_calendars
|
||||||
func ToTime(d Date) time.Time {
|
func JDateToTime(d Date) time.Time {
|
||||||
offset := -2
|
offset := -2
|
||||||
borderDate := Date{100, time.March, 2}
|
borderDate := Date{100, time.March, 2}
|
||||||
// We don't increase the offset for years divisible by 400, ie. every
|
// We don't increase the offset for years divisible by 400, ie. every
|
||||||
|
|
|
@ -67,7 +67,7 @@ func TestNextMonth(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestToTime(t *testing.T) {
|
func TestJDateToTime(t *testing.T) {
|
||||||
gDate := func(year int, month time.Month, day int) time.Time {
|
gDate := func(year int, month time.Month, day int) time.Time {
|
||||||
return time.Date(year, month, day, 0, 0, 0, 0, time.UTC)
|
return time.Date(year, month, day, 0, 0, 0, 0, time.UTC)
|
||||||
}
|
}
|
||||||
|
@ -138,7 +138,7 @@ func TestToTime(t *testing.T) {
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
testname := fmt.Sprintf("%v, %v", tt.d, tt.want)
|
testname := fmt.Sprintf("%v, %v", tt.d, tt.want)
|
||||||
t.Run(testname, func(t *testing.T) {
|
t.Run(testname, func(t *testing.T) {
|
||||||
ans := ToTime(tt.d)
|
ans := JDateToTime(tt.d)
|
||||||
if ans != tt.want {
|
if ans != tt.want {
|
||||||
t.Errorf("got %v, want %v", ans, tt.want)
|
t.Errorf("got %v, want %v", ans, tt.want)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue