115 lines
1.9 KiB
Go
115 lines
1.9 KiB
Go
package xtime
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
)
|
|
|
|
func TestGetDurationToNextHour(t *testing.T) {
|
|
now := Now()
|
|
target := Tomorrow()
|
|
d := GetDurationToNextHour()
|
|
fmt.Printf("now[%v] %s to next hour[%s] \n",
|
|
now,
|
|
d,
|
|
target,
|
|
)
|
|
}
|
|
|
|
func TestGetDurationToNextNHour(t *testing.T) {
|
|
n := 3
|
|
now := Now()
|
|
target := Tomorrow()
|
|
d := GetDurationToNextNHour(n)
|
|
fmt.Printf("now[%v] %s to next %d hour[%s] \n",
|
|
now,
|
|
d,
|
|
n,
|
|
target,
|
|
)
|
|
}
|
|
|
|
func TestGetDurationToTomorrow(t *testing.T) {
|
|
now := Now()
|
|
target := Tomorrow()
|
|
d := GetDurationToTomorrow()
|
|
fmt.Printf("now[%v](%s) %s to tomorrow[%s](%s) \n",
|
|
FormatDate(now),
|
|
now,
|
|
d,
|
|
FormatDate(target),
|
|
target,
|
|
)
|
|
}
|
|
|
|
func TestGetDurationToNextNDay(t *testing.T) {
|
|
n := 3
|
|
now := Now()
|
|
target := NextNDay(n)
|
|
d := GetDurationToNextNDay(n)
|
|
fmt.Printf("now[%v](%s) %s to next %v day[%s](%s) \n",
|
|
FormatDate(now),
|
|
now,
|
|
d,
|
|
n,
|
|
FormatDate(target),
|
|
target,
|
|
)
|
|
}
|
|
|
|
func TestGetDurationToNextWeek(t *testing.T) {
|
|
now := Now()
|
|
target := NextWeek()
|
|
d := GetDurationToNextWeek()
|
|
fmt.Printf("now[%v](%s) %s to next week[%s](%s) \n",
|
|
FormatWeek(now),
|
|
now,
|
|
d,
|
|
FormatWeek(target),
|
|
target,
|
|
)
|
|
}
|
|
|
|
func TestGetDurationToNextNWeek(t *testing.T) {
|
|
n := 3
|
|
now := Now()
|
|
target := NextNWeek(n)
|
|
d := GetDurationToNextNWeek(n)
|
|
fmt.Printf("now[%v](%s) %s to next %v week[%s](%s) \n",
|
|
FormatWeek(now),
|
|
now,
|
|
d,
|
|
n,
|
|
FormatWeek(target),
|
|
target,
|
|
)
|
|
}
|
|
|
|
func TestGetDurationToNextMonth(t *testing.T) {
|
|
now := Now()
|
|
target := NextMonth()
|
|
d := GetDurationToNextMonth()
|
|
fmt.Printf("now[%v](%s) %s to next month[%s](%s) \n",
|
|
FormatMonth(now),
|
|
now,
|
|
d,
|
|
FormatMonth(target),
|
|
target,
|
|
)
|
|
}
|
|
|
|
func TestGetDurationToNextNMonth(t *testing.T) {
|
|
n := 3
|
|
now := Now()
|
|
target := NextNMonth(n)
|
|
d := GetDurationToNextNMonth(n)
|
|
fmt.Printf("now[%v](%s) %s to next %v month[%s](%s) \n",
|
|
FormatMonth(now),
|
|
now,
|
|
d,
|
|
n,
|
|
FormatMonth(target),
|
|
target,
|
|
)
|
|
}
|