|
| 1 | +/** |
| 2 | + * Nextcloud - Tasks |
| 3 | + * |
| 4 | + * @author Raimund Schlüßler |
| 5 | + * |
| 6 | + * @copyright 2024 Raimund Schlüßler <[email protected]> |
| 7 | + * |
| 8 | + * This library is free software; you can redistribute it and/or |
| 9 | + * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE |
| 10 | + * License as published by the Free Software Foundation; either |
| 11 | + * version 3 of the License, or any later version. |
| 12 | + * |
| 13 | + * This library is distributed in the hope that it will be useful, |
| 14 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. |
| 17 | + * |
| 18 | + * You should have received a copy of the GNU Affero General Public |
| 19 | + * License along with this library. If not, see <http://www.gnu.org/licenses/>. |
| 20 | + * |
| 21 | + */ |
| 22 | + |
| 23 | +/** |
| 24 | + * Returns a formatted string for the due date |
| 25 | + * |
| 26 | + * @param {Task} task The task |
| 27 | + * @return {string} The formatted due date string |
| 28 | + */ |
| 29 | +export function dueDateString(task) { |
| 30 | + if (task.allDay) { |
| 31 | + return task.dueMoment.calendar(null, { |
| 32 | + // TRANSLATORS This is a string for moment.js. The square brackets escape the string from moment.js. Please translate the string and keep the brackets. |
| 33 | + sameDay: t('tasks', '[Due today]'), |
| 34 | + // TRANSLATORS This is a string for moment.js. The square brackets escape the string from moment.js. Please translate the string and keep the brackets. |
| 35 | + nextDay: t('tasks', '[Due tomorrow]'), |
| 36 | + // TRANSLATORS This is a string for moment.js. The square brackets escape the string from moment.js. "LL" will be replaced with a date, e.g. 'September 4 1986'. Please translate the string and keep the brackets and the "LL". |
| 37 | + nextWeek: t('tasks', '[Due on] LL'), |
| 38 | + // TRANSLATORS This is a string for moment.js. The square brackets escape the string from moment.js. Please translate the string, but keep the brackets. |
| 39 | + lastDay: t('tasks', '[Was due yesterday]'), |
| 40 | + // TRANSLATORS This is a string for moment.js. The square brackets escape the string from moment.js. "LL" will be replaced with a date, e.g. 'September 4 1986'. Please translate the string, but keep the brackets and the "LL". |
| 41 | + lastWeek: t('tasks', '[Was due on] LL'), |
| 42 | + sameElse(now) { |
| 43 | + if (this.isBefore(now)) { |
| 44 | + // TRANSLATORS This is a string for moment.js. The square brackets escape the string from moment.js. Please translate the string, but keep the brackets and the "LL". |
| 45 | + return t('tasks', '[Was due on] LL') |
| 46 | + } else { |
| 47 | + // TRANSLATORS This is a string for moment.js. The square brackets escape the string from moment.js. Please translate the string, but keep the brackets and the "LL". |
| 48 | + return t('tasks', '[Due on] LL') |
| 49 | + } |
| 50 | + }, |
| 51 | + }) |
| 52 | + } else { |
| 53 | + return task.dueMoment.calendar(null, { |
| 54 | + sameDay(now) { |
| 55 | + if (this.isBefore(now)) { |
| 56 | + // TRANSLATORS This is a string for moment.js. The square brackets escape the string from moment.js. "LT" will be replaced with a time, e.g. '08:30 PM'. Please translate the string and keep the brackets and the "LT". |
| 57 | + return t('tasks', '[Was due today at] LT') |
| 58 | + } else { |
| 59 | + // TRANSLATORS This is a string for moment.js. The square brackets escape the string from moment.js. "LT" will be replaced with a time, e.g. '08:30 PM'. Please translate the string and keep the brackets and the "LT". |
| 60 | + return t('tasks', '[Due today at] LT') |
| 61 | + } |
| 62 | + }, |
| 63 | + // TRANSLATORS This is a string for moment.js. The square brackets escape the string from moment.js. "LT" will be replaced with a time, e.g. '08:30 PM'. Please translate the string and keep the brackets and the "LT". |
| 64 | + nextDay: t('tasks', '[Due tomorrow at] LT'), |
| 65 | + // TRANSLATORS This is a string for moment.js. The square brackets escape the string from moment.js. "LT" will be replaced with a time, e.g. '08:30 PM'. Please translate the string and keep the brackets and the "LT". |
| 66 | + nextWeek: t('tasks', '[Due on] LL [at] LT'), |
| 67 | + // TRANSLATORS This is a string for moment.js. The square brackets escape the string from moment.js. "LT" will be replaced with a time, e.g. '08:30 PM'. Please translate the string and keep the brackets and the "LT". |
| 68 | + lastDay: t('tasks', '[Was due yesterday at] LT'), |
| 69 | + // TRANSLATORS This is a string for moment.js. The square brackets escape the string from moment.js. "LL" will be replaced with a date, e.g. 'September 4 1986' and "LT" will be replaced with a time, e.g. '08:30 PM'. Please translate the string and keep the brackets the "LL" and the "LT". |
| 70 | + lastWeek: t('tasks', '[Was due on] LL [at] LT'), |
| 71 | + sameElse(now) { |
| 72 | + if (this.isBefore(now)) { |
| 73 | + // TRANSLATORS This is a string for moment.js. The square brackets escape the string from moment.js. "LL" will be replaced with a date, e.g. 'September 4 1986' and "LT" will be replaced with a time, e.g. '08:30 PM'. Please translate the string and keep the brackets the "LL" and the "LT". |
| 74 | + return t('tasks', '[Was due on] LL [at] LT') |
| 75 | + } else { |
| 76 | + // TRANSLATORS This is a string for moment.js. The square brackets escape the string from moment.js. "LL" will be replaced with a date, e.g. 'September 4 1986' and "LT" will be replaced with a time, e.g. '08:30 PM'. Please translate the string and keep the brackets the "LL" and the "LT". |
| 77 | + return t('tasks', '[Due on] LL [at] LT') |
| 78 | + } |
| 79 | + }, |
| 80 | + }) |
| 81 | + } |
| 82 | +} |
| 83 | + |
| 84 | +/** |
| 85 | + * Returns a formatted string for the start date |
| 86 | + * |
| 87 | + * @param {Task} task The task |
| 88 | + * @return {string} The formatted start date string |
| 89 | + */ |
| 90 | +export function startDateString(task) { |
| 91 | + if (task.allDay) { |
| 92 | + return task.startMoment.calendar(null, { |
| 93 | + // TRANSLATORS This is a string for moment.js. The square brackets escape the string from moment.js. Please translate the string and keep the brackets. |
| 94 | + sameDay: t('tasks', '[Starts today]'), |
| 95 | + // TRANSLATORS This is a string for moment.js. The square brackets escape the string from moment.js. Please translate the string and keep the brackets. |
| 96 | + nextDay: t('tasks', '[Starts tomorrow]'), |
| 97 | + // TRANSLATORS This is a string for moment.js. The square brackets escape the string from moment.js. "LL" will be replaced with a date, e.g. 'September 4 1986'. Please translate the string, and keep the brackets and the "LL". |
| 98 | + nextWeek: t('tasks', '[Starts on] LL'), |
| 99 | + // TRANSLATORS This is a string for moment.js. The square brackets escape the string from moment.js. Please translate the string and keep the brackets. |
| 100 | + lastDay: t('tasks', '[Started yesterday]'), |
| 101 | + // TRANSLATORS This is a string for moment.js. The square brackets escape the string from moment.js. "LL" will be replaced with a date, e.g. 'September 4 1986'. Please translate the string, and keep the brackets and the "LL". |
| 102 | + lastWeek: t('tasks', '[Started on] LL'), |
| 103 | + sameElse(now) { |
| 104 | + if (this.isBefore(now)) { |
| 105 | + // TRANSLATORS This is a string for moment.js. The square brackets escape the string from moment.js. "LL" will be replaced with a date, e.g. 'September 4 1986'. Please translate the string, and keep the brackets and the "LL". |
| 106 | + return t('tasks', '[Started on] LL') |
| 107 | + } else { |
| 108 | + // TRANSLATORS This is a string for moment.js. The square brackets escape the string from moment.js. "LL" will be replaced with a date, e.g. 'September 4 1986'. Please translate the string, and keep the brackets and the "LL". |
| 109 | + return t('tasks', '[Starts on] LL') |
| 110 | + } |
| 111 | + }, |
| 112 | + }) |
| 113 | + } else { |
| 114 | + return task.startMoment.calendar(null, { |
| 115 | + sameDay(now) { |
| 116 | + if (this.isBefore(now)) { |
| 117 | + // TRANSLATORS This is a string for moment.js. The square brackets escape the string from moment.js. "LT" will be replaced with a time, e.g. '08:30 PM'. Please translate the string and keep the brackets and the "LT". |
| 118 | + return t('tasks', '[Started today at] LT') |
| 119 | + } else { |
| 120 | + // TRANSLATORS This is a string for moment.js. The square brackets escape the string from moment.js. "LT" will be replaced with a time, e.g. '08:30 PM'. Please translate the string and keep the brackets and the "LT". |
| 121 | + return t('tasks', '[Starts today at] LT') |
| 122 | + } |
| 123 | + }, |
| 124 | + // TRANSLATORS This is a string for moment.js. The square brackets escape the string from moment.js. "LT" will be replaced with a time, e.g. '08:30 PM'. Please translate the string and keep the brackets and the "LT". |
| 125 | + nextDay: t('tasks', '[Starts tomorrow at] LT'), |
| 126 | + // TRANSLATORS This is a string for moment.js. The square brackets escape the string from moment.js. "LL" will be replaced with a date, e.g. 'September 4 1986' and "LT" will be replaced with a time, e.g. '08:30 PM'. Please translate the string and keep the brackets the "LL" and the "LT". |
| 127 | + nextWeek: t('tasks', '[Starts on] LL [at] LT'), |
| 128 | + // TRANSLATORS This is a string for moment.js. The square brackets escape the string from moment.js. "LT" will be replaced with a time, e.g. '08:30 PM'. Please translate the string and keep the brackets and the "LT". |
| 129 | + lastDay: t('tasks', '[Started yesterday at] LT'), |
| 130 | + // TRANSLATORS This is a string for moment.js. The square brackets escape the string from moment.js. "LL" will be replaced with a date, e.g. 'September 4 1986' and "LT" will be replaced with a time, e.g. '08:30 PM'. Please translate the string and keep the brackets the "LL" and the "LT". |
| 131 | + lastWeek: t('tasks', '[Started on] LL [at] LT'), |
| 132 | + sameElse(now) { |
| 133 | + if (this.isBefore(now)) { |
| 134 | + // TRANSLATORS This is a string for moment.js. The square brackets escape the string from moment.js. "LL" will be replaced with a date, e.g. 'September 4 1986' and "LT" will be replaced with a time, e.g. '08:30 PM'. Please translate the string and keep the brackets the "LL" and the "LT". |
| 135 | + return t('tasks', '[Started on] LL [at] LT') |
| 136 | + } else { |
| 137 | + // TRANSLATORS This is a string for moment.js. The square brackets escape the string from moment.js. "LL" will be replaced with a date, e.g. 'September 4 1986' and "LT" will be replaced with a time, e.g. '08:30 PM'. Please translate the string and keep the brackets the "LL" and the "LT". |
| 138 | + return t('tasks', '[Starts on] LL [at] LT') |
| 139 | + } |
| 140 | + }, |
| 141 | + }) |
| 142 | + } |
| 143 | +} |
0 commit comments