diff --git a/src/tiles/list/tile-list.ts b/src/tiles/list/tile-list.ts index 99b0fa1a4..d450d7d36 100644 --- a/src/tiles/list/tile-list.ts +++ b/src/tiles/list/tile-list.ts @@ -218,7 +218,6 @@ export class TileList extends BaseTileComponent { if (isFirstMillisecondOfUTCYear(date)) { format = 'year-only'; } - return this.metadataTemplate(formatDate(date, format), msg('Published')); } diff --git a/src/utils/format-date.ts b/src/utils/format-date.ts index 18b88f523..129796a8e 100644 --- a/src/utils/format-date.ts +++ b/src/utils/format-date.ts @@ -18,12 +18,22 @@ export function formatDate( // the date is already in UTC timezone so we should not add timeZone here again. const options: Intl.DateTimeFormatOptions = {}; + console.log('defined formatDate: ', date); switch (format) { case 'year-only': // If we're only using the year, ensure we output the correct UTC year and not // the local year. If the local timezone is used, we can get strange off-by-one // errors due to quirks of timezone handling for older years. - return `${date.getUTCFullYear()}`; + // return `${date.getUTCFullYear()}`; + // Get the UTC year + const utcYear = Date.UTC( + date.getFullYear(), + date.getMonth(), + date.getDate(), + ); + console.log('return yearonly: ', new Date(utcYear)); + // Return the UTC year + return `${new Date(utcYear).getUTCFullYear()}`; case 'short': options.month = 'short'; options.year = 'numeric';