@@ 130-152 (lines=23) @@ | ||
127 | * @param $l IL10N |
|
128 | * @return mixed|string |
|
129 | */ |
|
130 | public function getTimeString($filetime, $now, $l) { |
|
131 | $difftime = $filetime->diff($now); |
|
132 | $years = $difftime->y; |
|
133 | $months = $difftime->m; |
|
134 | $days = $difftime->d; |
|
135 | $hours = $difftime->h; |
|
136 | $minutes = $difftime->i; |
|
137 | $seconds = $difftime->s; |
|
138 | $timestring = ""; |
|
139 | if ($timestring == "" && $years == 1) $timestring = str_replace('#', $years, $l->t("# year ago")); |
|
140 | if ($timestring == "" && $years > 0) $timestring = str_replace('#', $years, $l->t("# years ago")); |
|
141 | if ($timestring == "" && $months == 1) $timestring = str_replace('#', $months, $l->t("# month ago")); |
|
142 | if ($timestring == "" && $months > 0) $timestring = str_replace('#', $months, $l->t("# months ago")); |
|
143 | if ($timestring == "" && $days == 1) $timestring = str_replace('#', $days, $l->t("# day ago")); |
|
144 | if ($timestring == "" && $days > 0) $timestring = str_replace('#', $days, $l->t("# days ago")); |
|
145 | if ($timestring == "" && $hours == 1) $timestring = str_replace('#', $hours, $l->t("# hour ago")); |
|
146 | if ($timestring == "" && $hours > 0) $timestring = str_replace('#', $hours, $l->t("# hours ago")); |
|
147 | if ($timestring == "" && $minutes == 1) $timestring = str_replace('#', $minutes, $l->t("# minute ago")); |
|
148 | if ($timestring == "" && $minutes > 0) $timestring = str_replace('#', $minutes, $l->t("# minutes ago")); |
|
149 | if ($timestring == "" && $seconds == 1) $timestring = str_replace('#', $seconds, $l->t("# second ago")); |
|
150 | if ($timestring == "" && $seconds > 0) $timestring = str_replace('#', $seconds, $l->t("# seconds ago")); |
|
151 | return $timestring; |
|
152 | } |
|
153 | ||
154 | /** |
|
155 | * @param $str |
@@ 79-102 (lines=24) @@ | ||
76 | * @param $now \DateTime |
|
77 | * @return mixed|string |
|
78 | */ |
|
79 | public function getTimeString($filetime, $now) { |
|
80 | $l = \OCP\Util::getL10N('ownnote'); |
|
81 | $difftime = $filetime->diff($now); |
|
82 | $years = $difftime->y; |
|
83 | $months = $difftime->m; |
|
84 | $days = $difftime->d; |
|
85 | $hours = $difftime->h; |
|
86 | $minutes = $difftime->i; |
|
87 | $seconds = $difftime->s; |
|
88 | $timestring = ""; |
|
89 | if ($timestring == "" && $years == 1) $timestring = str_replace('#', $years, $l->t("# year ago")); |
|
90 | if ($timestring == "" && $years > 0) $timestring = str_replace('#', $years, $l->t("# years ago")); |
|
91 | if ($timestring == "" && $months == 1) $timestring = str_replace('#', $months, $l->t("# month ago")); |
|
92 | if ($timestring == "" && $months > 0) $timestring = str_replace('#', $months, $l->t("# months ago")); |
|
93 | if ($timestring == "" && $days == 1) $timestring = str_replace('#', $days, $l->t("# day ago")); |
|
94 | if ($timestring == "" && $days > 0) $timestring = str_replace('#', $days, $l->t("# days ago")); |
|
95 | if ($timestring == "" && $hours == 1) $timestring = str_replace('#', $hours, $l->t("# hour ago")); |
|
96 | if ($timestring == "" && $hours > 0) $timestring = str_replace('#', $hours, $l->t("# hours ago")); |
|
97 | if ($timestring == "" && $minutes == 1) $timestring = str_replace('#', $minutes, $l->t("# minute ago")); |
|
98 | if ($timestring == "" && $minutes > 0) $timestring = str_replace('#', $minutes, $l->t("# minutes ago")); |
|
99 | if ($timestring == "" && $seconds == 1) $timestring = str_replace('#', $seconds, $l->t("# second ago")); |
|
100 | if ($timestring == "" && $seconds > 0) $timestring = str_replace('#', $seconds, $l->t("# seconds ago")); |
|
101 | return $timestring; |
|
102 | } |
|
103 | ||
104 | ||
105 | /** |