dashy icon indicating copy to clipboard operation
dashy copied to clipboard

[BUG] Public Holidays widget returns Invalid Date on Safari

Open pdxrlk opened this issue 1 year ago • 2 comments
trafficstars

Environment

Self-Hosted (Docker)

System

Safari (macOS)

Version

2.1.2

Describe the problem

The Public Holidays widget displays "Invalid Date" for all dates on Safari (MacOs). It works fine on Firefox and Chrome. Screenshot 2024-04-16 at 1 38 36 PM

Additional info

I suspect the issue is with the toLocaleDataString call in MiscHelper.js. Maybe use moment.js instead? (see for example, this discussion).

/* Given a timestamp, returns formatted date, in local format */
export const timestampToDate = (timestamp) => {
  const localFormat = navigator.language;
  const dateFormat = {
    weekday: 'short', day: 'numeric', month: 'short', year: 'numeric',
  };
  const date = new Date(timestamp).toLocaleDateString(localFormat, dateFormat);
  return `${date}`;
};

Please tick the boxes

pdxrlk avatar Apr 16 '24 20:04 pdxrlk

If you're enjoying Dashy, consider dropping us a ⭐
🤖 I'm a bot, and this message was automated

liss-bot avatar Apr 16 '24 20:04 liss-bot

Linking this to #894

CrazyWolf13 avatar Apr 16 '24 23:04 CrazyWolf13

I have the same problem in safari (Monterey), the curious thing is that is only reads one date Christmas Day, but shows a different date that what is in the file. Show Christmas Day is December 24th, file says it is December 25th, all other dates show as "INVALID DATE". Very curious. image

umolinar avatar May 09 '24 21:05 umolinar

Which config did you use for this? I'm interested to know the region, as that would let me send an API request, and see what weird format the dates are coming back in.

And if you pop open the browser console, and run navigator.language - what's the output?


I suspect the issue is with the toLocaleDataString call in MiscHelper.js. Maybe use moment.js instead? (see for example, this discussion).

Thanks @pdxrlk, but I'm hesitant to add in Moment.js as since that StackOverflow discussion was written, in 2010, we now have all the date parsing needed included in the browser APIs using toLocaleDateString, and unless you're using a reallyyyy old version of Safari, then it should be supported there as well.

Lissy93 avatar May 09 '24 22:05 Lissy93

Thank you region is SLV ( America/El_Salvador)GraciasUlises MolinaOn May 9, 2024, at 4:16 PM, Alicia Sykes @.***> wrote: Which config did you use for this? I'm interested to know the region, as that would let me send an API request, and see what weird format the dates are coming back in. And if you pop open the browser console, and run navigator.language - what's the output?

I suspect the issue is with the toLocaleDataString call in MiscHelper.js. Maybe use moment.js instead? (see for example, this discussion).

Thanks @pdxrlk, but I'm hesitant to add in Moment.js as since that StackOverflow discussion was written, in 2010, we now have all the date parsing needed included in the browser APIs using toLocaleDateString, and unless you're using a reallyyyy old version of Safari, then it should be supported there as well.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>

umolinar avatar May 09 '24 23:05 umolinar

Hey @umolinar,

Thanks for the info. I just tested, but it seems to work okay for me using the below config

image

  - type: public-holidays
    options:
      country: SV
      holidayType: all
      monthsToShow: 12
      lang: en

Lissy93 avatar May 09 '24 23:05 Lissy93

It does not for me, at the moment I am on my iPhone

Gracias, Thanks, Ulises Molina +503 7049 5062

On Thu, May 9, 2024 at 5:42 PM Alicia Sykes @.***> wrote:

Hey @umolinar https://github.com/umolinar,

Thanks for the info. I just tested, but it seems to work okay for me using the below config

image.png (view on web) https://github.com/Lissy93/dashy/assets/1862727/1fe54417-15d3-4e4a-92a2-be2c3f4fb8dd

  • type: public-holidays options: country: SV holidayType: all monthsToShow: 12 lang: en

— Reply to this email directly, view it on GitHub https://github.com/Lissy93/dashy/issues/1532#issuecomment-2103610072, or unsubscribe https://github.com/notifications/unsubscribe-auth/BGEOKVTPKFA73ARXIFDIFKLZBQCXXAVCNFSM6AAAAABGKBVWJCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMBTGYYTAMBXGI . You are receiving this because you were mentioned.Message ID: @.***>

umolinar avatar May 09 '24 23:05 umolinar

I can confirm on my iPad the dates do not show up.

CrazyWolf13 avatar May 09 '24 23:05 CrazyWolf13

Thank you, if I can help, let me know!GraciasUlises MolinaOn May 9, 2024, at 5:50 PM, Tobias @.***> wrote: I can confirm on my iPad the dates do not show up.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>

umolinar avatar May 09 '24 23:05 umolinar

Thanks @CrazyWolf13 and @umolinar, I think I see the issue - Safari parses dates weirdly. Fix coming in #1577

P.s. I'm a bit jealous about how many public holidays you get!! 🏖️😆

Lissy93 avatar May 10 '24 00:05 Lissy93

Thank you, I am sure Mexico gets more!

Gracias, Thanks, Ulises Molina +503 7049 5062

On Thu, May 9, 2024 at 6:06 PM Alicia Sykes @.***> wrote:

Thanks @CrazyWolf13 https://github.com/CrazyWolf13 and @umolinar https://github.com/umolinar, I think I see the issue - Safari parses dates weirdly. Fix coming in #1577 https://github.com/Lissy93/dashy/pull/1577

P.s. I'm a bit jealous about how many public holidays you get!! 🏖️😆

— Reply to this email directly, view it on GitHub https://github.com/Lissy93/dashy/issues/1532#issuecomment-2103626880, or unsubscribe https://github.com/notifications/unsubscribe-auth/BGEOKVWQW5HSKU6ITZ2SQX3ZBQFQTAVCNFSM6AAAAABGKBVWJCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMBTGYZDMOBYGA . You are receiving this because you were mentioned.Message ID: @.***>

umolinar avatar May 10 '24 00:05 umolinar

Sorry last question, what directory and what file do I make these changes? Or do I need to reinstall?GraciasUlises MolinaOn May 9, 2024, at 6:09 PM, Alicia Sykes @.***> wrote: Closed #1532 as completed via eea193a.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>

umolinar avatar May 10 '24 00:05 umolinar

Sorry last question, what directory and what file do I make these changes? Or do I need to reinstall?GraciasUlises MolinaOn May 9, 2024, at 6:09 PM, Alicia Sykes @.> wrote: Closed #1532 as completed via eea193a. —Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.>

As soon as a new release will happen, those changes will be included. If you have docker, you can just re-pull the :latest tag of the dashy image.

If you need furter help let me know.

CrazyWolf13 avatar May 10 '24 10:05 CrazyWolf13