-
{{ getFormattedDateTitle(event.startDate, true) }}
-
-
- {{ getRelativeString(defaultDate, event.startDate) }}
+
+
+
+ {{ getFormattedDateTitle(event.startDate, true) }}
+
+
+
+
+ Du {{ getFormattedDateTitle(event.startDate, true) }} au
+ {{ getFormattedDateTitle(event.endDate, true) }}
+
+
+
+
+
+
+ {{ dateDifference }}
+
+
+ Pendant {{ dateDuration }}
+
+
diff --git a/src/data/Events.ts b/src/data/Events.ts
index f42c3be..26258bf 100644
--- a/src/data/Events.ts
+++ b/src/data/Events.ts
@@ -55,7 +55,7 @@ export const regularEvents: CalendarEvent[] = [
startDate: { day: 30, month: 2, year: 340 },
endDate: { day: 27, month: 9, year: 355 },
description:
- "Le Grand Conseil Kaldélien ordonne la construction d'une muraille autour des Plaines de Poussières, afin de contenir les quelques démons y sortant.",
+ "Le Grand Conseil Kaldélien ordonne la construction d'une muraille autour des Plaines de Poussières, afin de contenir les démons y sortant.",
category: 'construction',
wiki: 'https://alexcreates.fr/leim/index.php/Plaines_de_poussi%C3%A8re',
hidden: true
diff --git a/src/models/Date.ts b/src/models/Date.ts
index feaaec8..209819a 100644
--- a/src/models/Date.ts
+++ b/src/models/Date.ts
@@ -90,7 +90,11 @@ export function getDifferenceInDays(baseDate: LeimDate, relativeDate: LeimDate):
* @param relativeDate The year to compare it to
* @returns A string with info on how the relative date differs to the base date
*/
-export function getRelativeString(baseDate: LeimDate, relativeDate: LeimDate): string {
+export function getRelativeString(
+ baseDate: LeimDate,
+ relativeDate: LeimDate,
+ formatting: 'compact' | 'complex' = 'complex'
+): string {
const differenceInDays: number = getDifferenceInDays(baseDate, relativeDate)
let output: string = ''
let direction: 'past' | 'present' | 'future' = 'present'
@@ -103,31 +107,33 @@ export function getRelativeString(baseDate: LeimDate, relativeDate: LeimDate): s
direction = 'past'
}
- // Handle if it's the same date
- if (direction === 'present') {
- return "Aujourd'hui"
- }
- if (differenceInDays === -2) {
- return 'Avant-hier'
- }
- if (differenceInDays === -1) {
- return 'Hier'
- }
- if (differenceInDays === 1) {
- return 'Demain'
- }
- if (differenceInDays === 2) {
- return 'Après-demain'
- }
+ if (formatting === 'complex') {
+ // Handle if it's the same date
+ if (direction === 'present') {
+ return "Aujourd'hui"
+ }
+ if (differenceInDays === -2) {
+ return 'Avant-hier'
+ }
+ if (differenceInDays === -1) {
+ return 'Hier'
+ }
+ if (differenceInDays === 1) {
+ return 'Demain'
+ }
+ if (differenceInDays === 2) {
+ return 'Après-demain'
+ }
- // Get relevant prefix for the string
- if (direction === 'future') {
- directionPrefix = 'Dans'
- } else if (direction === 'past') {
- directionPrefix = 'Il y a'
- }
+ // Get relevant prefix for the string
+ if (direction === 'future') {
+ directionPrefix = 'Dans '
+ } else if (direction === 'past') {
+ directionPrefix = 'Il y a '
+ }
- output += directionPrefix
+ output += directionPrefix
+ }
const yearPackets: number = Math.abs(Math.trunc(differenceInDays / daysPerYear))
const monthPackets: number = Math.abs(Math.trunc(differenceInDays / daysPerMonth) % monthsPerYear)
@@ -138,9 +144,9 @@ export function getRelativeString(baseDate: LeimDate, relativeDate: LeimDate): s
// Assign year part
if (yearPackets) {
if (yearPackets === 1) {
- output += ` ${yearPackets} an`
+ output += `${yearPackets} an`
} else {
- output += ` ${yearPackets} ans`
+ output += `${yearPackets} ans`
}
}