diff options
| author | John R. Lenton <jlenton@gmail.com> | 2018-03-02 13:05:33 +0000 |
|---|---|---|
| committer | John R. Lenton <jlenton@gmail.com> | 2018-03-02 13:40:58 +0000 |
| commit | 611f8d96e281089d8327a10aa718d1547ba16243 (patch) | |
| tree | 38b8ee952c0f8b3bbf8fdbe0d5a9b95406cb3939 | |
| parent | ca103056d91e3ad66623c2c4c9a2edde48623816 (diff) | |
timeutil: i18n.NG now takes ints.
| -rw-r--r-- | timeutil/human.go | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/timeutil/human.go b/timeutil/human.go index c432c7cd3e..650f69205d 100644 --- a/timeutil/human.go +++ b/timeutil/human.go @@ -34,25 +34,17 @@ func noon(t time.Time) time.Time { // Human turns the time into a relative expression of time meant for human // consumption. -// Human(t) --> "today at 07:47 " +// Human(t) --> "today at 07:47" func Human(then time.Time) string { return humanTimeSince(then.Local(), time.Now().Local()) } -func ngd(d int) uint32 { - const max = 1000000 - if d > max { - return uint32((d % max) + max) - } - return uint32(d) -} - func humanTimeSince(then, now time.Time) string { d := int(math.Floor(noon(then).Sub(noon(now)).Hours() / 24)) switch { case d < -1: // TRANSLATORS: %d will be at least 2; the singular is only included to help gettext - return fmt.Sprintf(then.Format(i18n.NG("in %d day, at 15:04 MST", "%d days ago, at 15:04 MST", ngd(-d))), -d) + return fmt.Sprintf(then.Format(i18n.NG("%d day ago, at 15:04 MST", "%d days ago, at 15:04 MST", -d)), -d) case d == -1: return then.Format(i18n.G("yesterday at 15:04 MST")) case d == 0: @@ -61,7 +53,7 @@ func humanTimeSince(then, now time.Time) string { return then.Format(i18n.G("tomorrow at 15:04 MST")) case d > 1: // TRANSLATORS: %d will be at least 2; the singular is only included to help gettext - return fmt.Sprintf(then.Format(i18n.NG("in %d day, at 15:04 MST", "in %d days, at 15:04 MST", ngd(d))), d) + return fmt.Sprintf(then.Format(i18n.NG("in %d day, at 15:04 MST", "in %d days, at 15:04 MST", d)), d) default: // the following message is brought to you by Joel Armando, the self-described awesome and sexy mathematician. panic("you have broken the law of trichotomy! ℤ is no longer totally ordered! chaos ensues!") |
