Skip to content

Conversation

@mamico
Copy link
Member

@mamico mamico commented Oct 20, 2025

  • aggiunto in datetimewidget la gestione della timezone, così come arriva dal server (non è corretto che le date vengono mostrate con la timezone del client)
  • nella tabella per la trasparenza se le date di pubblicazioen contengono l'orra, va stampata
  • sistemato un errore dove veniva stampato il mese (MM) anziichè i minuti (mm)
  • avendo aggiunto moment-timezone per gestire la timezone con moment (dal momento che ora quello c'è) serve che nella build webpack vengaa introdotto un plugin cche riduce la dimensione del bundle aggiungendo solo le timezone realmente usate.

razzle.config.js del progetto (nel nostro caso io-sanita)

const MomentTimezoneDataPlugin = require('moment-timezone-data-webpack-plugin');
...
const customModifyWebpackConfig = ({
  env: { target, dev },
  webpackConfig,
  webpackObject,
  options,
}) => {
  const config = modifyWebpackConfig({
    env: { target, dev },
    webpackConfig,
    webpackObject,
    options,
    paths: {appBuildPublic: `${projectRootPath}/public`},
  });
  config.plugins.push(
    new MomentTimezoneDataPlugin({
        matchZones: /^Europe\/Rome$/,
        startYear: 1970,
        endYear: 2030,
    })
  );
...

In generale il problam è che aver messo in modo esplicito deii nomi dei campi e come formatttarli rende poco flessibile la tabella, perchè in alcuni casi si vorrebbe che dei campi con quel nome avessero sia data che ora.

Ho riportato qui dei casi spsecifiche che si potrebbero anche gestire con una customization completa del jsx, ma servirebbe a mio avviso ripensare a montet la cosa.

Lascio in draft avendo comunque risolto il caso specifico con una customization

@mamico
Copy link
Member Author

mamico commented Oct 20, 2025

aggiungo però che c'era anche un errore con 'HH:MM' dove invece deve essere 'HH:mm' perchè MM è il mese, mentre mm i minuti

@pnicolli pnicolli requested a review from Copilot October 21, 2025 15:16
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes date handling and timezone issues in transparency tables by introducing timezone-aware date formatting using moment-timezone, and correcting a date format typo where month (MM) was used instead of minutes (mm).

Key Changes:

  • Added timezone support to DatetimeWidget using moment-timezone with timezone from server configuration
  • Fixed date formatting in transparency tables to conditionally show time when present in publication dates
  • Corrected format string from 'HH:MM' to 'HH:mm' to properly display minutes

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
src/customizations/volto/components/theme/Widgets/DatetimeWidget.jsx New customization that applies timezone-aware formatting to datetime values
src/components/View/Bando/Dates.jsx Updated to use timezone-aware moment formatting instead of pre-formatted dates
src/components/Blocks/Listing/Table/TableTemplate.jsx Fixed minute format typo and added logic to conditionally display time based on date content
package.json Added moment-timezone dependency

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.


import { useSelector } from 'react-redux';
import { viewDate } from 'io-sanita-theme/helpers';
import moment from 'moment-timezone';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possiamo importarlo lazy? Non ho guardato come sia stato importato altrove nel repo

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possiamo importarlo lazy? Non ho guardato come sia stato importato altrove nel repo

il lavoro di avere moment lazy su Volto è un lavoro "a metà", fare una libreria lazy "a metà" è più la perdita che il guadagno. Però, nello specifico qui posso faare moment-timezone lazy e vedere se c'è un guadagno reale.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sposto la verifica per il lazy su una issue a parte

@mamico mamico requested a review from pnicolli November 3, 2025 08:43
@mamico mamico marked this pull request as ready for review November 3, 2025 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants