diff --git a/components/common/DateFilter.js b/components/common/DateFilter.js index 8e50e95a6..d568a889e 100644 --- a/components/common/DateFilter.js +++ b/components/common/DateFilter.js @@ -18,6 +18,10 @@ export const filterOptions = [ ), value: '24hour', }, + { + label: , + value: '-1day', + }, { label: , value: '1week', diff --git a/lang/ca-ES.json b/lang/ca-ES.json index 8ab41de3f..dcbada596 100644 --- a/lang/ca-ES.json +++ b/lang/ca-ES.json @@ -62,6 +62,7 @@ "label.username": "Nom d'usuari", "label.view-details": "Veure els detalls", "label.websites": "Llocs web", + "label.yesterday": "Ahir", "message.active-users": "{x} {x, plural, one {visitant actual} other {visitants actuals}}", "message.confirm-delete": "Segur que vols esborrar {target}?", "message.confirm-reset": "Segur que vols restablir les estadístiques de {target}?", diff --git a/lang/de-DE.json b/lang/de-DE.json index 297de6a2e..f95f4fc85 100644 --- a/lang/de-DE.json +++ b/lang/de-DE.json @@ -62,6 +62,7 @@ "label.username": "Benutzername", "label.view-details": "Details anzeigen", "label.websites": "Webseiten", + "label.yesterday": "Gestern", "message.active-users": "{x} {x, plural, one {aktiver Besucher} other {aktive Besucher}}", "message.confirm-delete": "Sind Sie sich sicher, {target} zu löschen?", "message.confirm-reset": "Sind Sie sicher, dass Sie die Statistiken von {target} zurücksetzen wollen?", diff --git a/lang/en-GB.json b/lang/en-GB.json index bc253a60a..aa5e3ae36 100644 --- a/lang/en-GB.json +++ b/lang/en-GB.json @@ -62,6 +62,7 @@ "label.username": "Username", "label.view-details": "View details", "label.websites": "Websites", + "label.yesterday": "Yesterday", "message.active-users": "{x} current {x, plural, one {visitor} other {visitors}}", "message.confirm-delete": "Are you sure you want to delete {target}?", "message.confirm-reset": "Are you sure you want to reset {target}'s statistics?", diff --git a/lang/en-US.json b/lang/en-US.json index bc253a60a..aa5e3ae36 100644 --- a/lang/en-US.json +++ b/lang/en-US.json @@ -62,6 +62,7 @@ "label.username": "Username", "label.view-details": "View details", "label.websites": "Websites", + "label.yesterday": "Yesterday", "message.active-users": "{x} current {x, plural, one {visitor} other {visitors}}", "message.confirm-delete": "Are you sure you want to delete {target}?", "message.confirm-reset": "Are you sure you want to reset {target}'s statistics?", diff --git a/lang/es-MX.json b/lang/es-MX.json index e9b02c1d0..ecefd17be 100644 --- a/lang/es-MX.json +++ b/lang/es-MX.json @@ -62,6 +62,7 @@ "label.username": "Nombre de usuario", "label.view-details": "Ver detalles", "label.websites": "Sitios", + "label.yesterday": "Ayer", "message.active-users": "{x} {x, plural, one {activo} other {activos}}", "message.confirm-delete": "¿Estás seguro(a) de querer eliminar {target}?", "message.confirm-reset": "¿Seguro que deseas restablecer las estadísticas de {target}?", diff --git a/lang/fr-FR.json b/lang/fr-FR.json index c4034fc32..0ba89b1d0 100644 --- a/lang/fr-FR.json +++ b/lang/fr-FR.json @@ -62,6 +62,7 @@ "label.username": "Nom d'utilisateur", "label.view-details": "Voir les details", "label.websites": "Sites", + "label.yesterday": "Hier", "message.active-users": "{x} {x, plural, one {visiteur} other {visiteurs}} actuellement", "message.confirm-delete": "Êtes-vous sûr de vouloir supprimer {target} ?", "message.confirm-reset": "Êtes-vous sûr de vouloir réinitialiser les statistiques de {target} ?", diff --git a/lang/it-IT.json b/lang/it-IT.json index 4069bb9c4..356e226ca 100644 --- a/lang/it-IT.json +++ b/lang/it-IT.json @@ -62,6 +62,7 @@ "label.username": "Nome utente", "label.view-details": "Vedi dettagli", "label.websites": "Siti web", + "label.yesterday": "Ieri", "message.active-users": "{x} {x, plural, one {visitatore} other {visitatori}} online", "message.confirm-delete": "Sei sicuro di voler eliminare {target}?", "message.confirm-reset": "Sei sicuro di voler azzerare le statistiche di {target}?", diff --git a/lib/date.js b/lib/date.js index 6897df213..cae39ce41 100644 --- a/lib/date.js +++ b/lib/date.js @@ -7,6 +7,8 @@ import { addYears, subHours, subDays, + subMonths, + subYears, startOfMinute, startOfHour, startOfDay, @@ -39,7 +41,7 @@ export function getDateRange(value, locale = 'en-US') { const now = new Date(); const dateLocale = getDateLocale(locale); - const match = value.match(/^(?[0-9]+)(?hour|day|week|month|year)$/); + const match = value.match(/^(?[0-9-]+)(?hour|day|week|month|year)$/); if (!match) return; @@ -78,6 +80,39 @@ export function getDateRange(value, locale = 'en-US') { } } + if (+num === -1) { + switch (unit) { + case 'day': + return { + startDate: subDays(startOfDay(now), 1), + endDate: subDays(endOfDay(now), 1), + unit: 'hour', + value, + }; + case 'week': + return { + startDate: subDays(startOfWeek(now, { locale: dateLocale }), 7), + endDate: subDays(endOfWeek(now, { locale: dateLocale }), 1), + unit: 'day', + value, + }; + case 'month': + return { + startDate: subMonths(startOfMonth(now), 1), + endDate: subMonths(endOfMonth(now), 1), + unit: 'day', + value, + }; + case 'year': + return { + startDate: subYears(startOfYear(now), 1), + endDate: subYears(endOfYear(now), 1), + unit: 'month', + value, + }; + } + } + switch (unit) { case 'day': return { diff --git a/public/intl/messages/ca-ES.json b/public/intl/messages/ca-ES.json index af1fbd6d4..9b6013e78 100644 --- a/public/intl/messages/ca-ES.json +++ b/public/intl/messages/ca-ES.json @@ -397,6 +397,12 @@ "value": "Llocs web" } ], + "label.yesterday": [ + { + "type": 0, + "value": "Ahir" + } + ], "message.active-users": [ { "type": 1, diff --git a/public/intl/messages/de-DE.json b/public/intl/messages/de-DE.json index aa4c9d9f0..ee9995445 100644 --- a/public/intl/messages/de-DE.json +++ b/public/intl/messages/de-DE.json @@ -397,6 +397,12 @@ "value": "Webseiten" } ], + "label.yesterday": [ + { + "type": 0, + "value": "Gestern" + } + ], "message.active-users": [ { "type": 1, diff --git a/public/intl/messages/en-GB.json b/public/intl/messages/en-GB.json index 721c765aa..ecb654d1b 100644 --- a/public/intl/messages/en-GB.json +++ b/public/intl/messages/en-GB.json @@ -397,6 +397,12 @@ "value": "Websites" } ], + "label.yesterday": [ + { + "type": 0, + "value": "Yesterday" + } + ], "message.active-users": [ { "type": 1, diff --git a/public/intl/messages/en-US.json b/public/intl/messages/en-US.json index 721c765aa..ecb654d1b 100644 --- a/public/intl/messages/en-US.json +++ b/public/intl/messages/en-US.json @@ -397,6 +397,12 @@ "value": "Websites" } ], + "label.yesterday": [ + { + "type": 0, + "value": "Yesterday" + } + ], "message.active-users": [ { "type": 1, diff --git a/public/intl/messages/es-MX.json b/public/intl/messages/es-MX.json index 761018ba7..d70fb6e79 100644 --- a/public/intl/messages/es-MX.json +++ b/public/intl/messages/es-MX.json @@ -397,6 +397,12 @@ "value": "Sitios" } ], + "label.yesterday": [ + { + "type": 0, + "value": "Ayer" + } + ], "message.active-users": [ { "type": 1, diff --git a/public/intl/messages/fr-FR.json b/public/intl/messages/fr-FR.json index 229c6691a..4f954a012 100644 --- a/public/intl/messages/fr-FR.json +++ b/public/intl/messages/fr-FR.json @@ -389,6 +389,12 @@ "value": "Sites" } ], + "label.yesterday": [ + { + "type": 0, + "value": "Hier" + } + ], "message.active-users": [ { "type": 1, diff --git a/public/intl/messages/it-IT.json b/public/intl/messages/it-IT.json index 5ff6beee0..6e0610955 100644 --- a/public/intl/messages/it-IT.json +++ b/public/intl/messages/it-IT.json @@ -397,6 +397,12 @@ "value": "Siti web" } ], + "label.yesterday": [ + { + "type": 0, + "value": "Ieri" + } + ], "message.active-users": [ { "type": 1,