felixmosh / bull-board

🎯 Queue background jobs inspector
MIT License
2.26k stars 359 forks source link

feat: custom job timeline date format #745

Closed HitomaruKonpaku closed 4 months ago

HitomaruKonpaku commented 4 months ago

743

Seem like Timeline is the only place that have date/time format, I didn't check other page/component

felixmosh commented 4 months ago

In my opinion this field should be inside locale field, WDYT?

HitomaruKonpaku commented 4 months ago

In my opinion this field should be inside locale field, WDYT?

Hmm I'm not really sure about that.

Will follow your call, but imo it isn't really related to locale since it will now follow the provided format without locale info

felixmosh commented 4 months ago

It is a locale matter, like language (the lng property), no?

HitomaruKonpaku commented 4 months ago

I think it is more of a standard (like ISO 8601) 🤔

Anyway, do you wish to move it into locale ? 😄

felixmosh commented 4 months ago

I'm consulting with you 😄

You convinced me, I will review it soon. Thank you for the PR

felixmosh commented 4 months ago

I've reviewed the PR. I don't like the fact that you are using dateFns.format. can we make some map from strings to Intl config? Maybe expose the entire Intl options

HitomaruKonpaku commented 4 months ago

The thing with Intl.DateTimeFormat is that you can not specify exact format (or maybe I don't know how, please help me on this)

Like with this options (Intl.DateTimeFormat(locale, options)), based on locale config of the app (en-US)

    {
      year: 'numeric',
      month: '2-digit',
      day: '2-digit',
      hour: '2-digit',
      minute: '2-digit',
      second: '2-digit',
      hour12: false,
    }
felixmosh commented 4 months ago

Hi, maybe the undefined option here will help you?

console.log(event.toLocaleDateString(undefined, options));
// expected output (varies according to local timezone and default locale): Thursday, December 20, 2012

taken from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString

HitomaruKonpaku commented 4 months ago

Hi there @felixmosh

This is the result I got

image

felixmosh commented 4 months ago

Ok, I see that it doesn't solves your issue. I will approve it, and will refactor the it a bit, thank you 🙏

felixmosh commented 4 months ago

Released in v5.18.2