diff options
author | dartcafe <github@dartcafe.de> | 2017-10-22 08:52:28 +0300 |
---|---|---|
committer | dartcafe <github@dartcafe.de> | 2017-10-22 08:52:28 +0300 |
commit | 9c08e3a4a690b5a501889e8178b99fac01f63977 (patch) | |
tree | ed6de9e0084d533a4a9dea3aedbf6d913a715ea9 /lib/private | |
parent | 4ac77b891c92594aed6603803de3cd527c3c4baa (diff) |
Fix future time spans
Signed-off-by: dartcafe <github@dartcafe.de>
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/DateTimeFormatter.php | 54 |
1 files changed, 45 insertions, 9 deletions
diff --git a/lib/private/DateTimeFormatter.php b/lib/private/DateTimeFormatter.php index 3d0a4dd620c..a8355d886f2 100644 --- a/lib/private/DateTimeFormatter.php +++ b/lib/private/DateTimeFormatter.php @@ -159,17 +159,41 @@ class DateTimeFormatter implements \OCP\IDateTimeFormatter { if ($dateInterval->y == 0 && $dateInterval->m == 0 && $dateInterval->d == 0) { return (string) $l->t('today'); } else if ($dateInterval->y == 0 && $dateInterval->m == 0 && $dateInterval->d == 1) { - return (string) $l->t('yesterday'); + if ($timestamp > $baseTimestamp) { + return (string) $l->t('tomorrow'); + } else { + return (string) $l->t('yesterday'); + } } else if ($dateInterval->y == 0 && $dateInterval->m == 0) { - return (string) $l->n('%n day ago', '%n days ago', $dateInterval->d); + if ($timestamp > $baseTimestamp) { + return (string) $l->n('in %n day', 'in %n days', $dateInterval->d); + } else { + return (string) $l->n('%n day ago', '%n days ago', $dateInterval->d); + } } else if ($dateInterval->y == 0 && $dateInterval->m == 1) { - return (string) $l->t('last month'); + if ($timestamp > $baseTimestamp) { + return (string) $l->t('next month'); + } else { + return (string) $l->t('last month'); + } } else if ($dateInterval->y == 0) { - return (string) $l->n('%n month ago', '%n months ago', $dateInterval->m); + if ($timestamp > $baseTimestamp) { + return (string) $l->n('in %n month', 'in %n months', $dateInterval->m); + } else { + return (string) $l->n('%n month ago', '%n months ago', $dateInterval->m); + } } else if ($dateInterval->y == 1) { - return (string) $l->t('last year'); + if ($timestamp > $baseTimestamp) { + return (string) $l->t('next year'); + } else { + return (string) $l->t('last year'); + } + } + if ($timestamp > $baseTimestamp) { + return (string) $l->n('in %n year', 'in %n years', $dateInterval->y); + } else { + return (string) $l->n('%n year ago', '%n years ago', $dateInterval->y); } - return (string) $l->n('%n year ago', '%n years ago', $dateInterval->y); } /** @@ -219,11 +243,23 @@ class DateTimeFormatter implements \OCP\IDateTimeFormatter { } if ($diff->h > 0) { - return (string) $l->n('%n hour ago', '%n hours ago', $diff->h); + if ($timestamp > $baseTimestamp) { + return (string) $l->n('in %n hour', 'in %n hours', $diff->h); + } else { + return (string) $l->n('%n hour ago', '%n hours ago', $diff->h); + } } else if ($diff->i > 0) { - return (string) $l->n('%n minute ago', '%n minutes ago', $diff->i); + if ($timestamp > $baseTimestamp) { + return (string) $l->n('in %n minute', 'in %n minutes', $diff->i); + } else { + return (string) $l->n('%n minute ago', '%n minutes ago', $diff->i); + } + } + if ($timestamp > $baseTimestamp) { + return (string) $l->t('in a few seconds'); + } else { + return (string) $l->t('seconds ago'); } - return (string) $l->t('seconds ago'); } /** |