Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Public Holidays widget returns Invalid Date on Safari #1532

Closed
5 tasks done
pdxrlk opened this issue Apr 16, 2024 · 13 comments
Closed
5 tasks done

[BUG] Public Holidays widget returns Invalid Date on Safari #1532

pdxrlk opened this issue Apr 16, 2024 · 13 comments
Assignees
Labels
🐛 Bug [ISSUE] Ticket describing something that isn't working

Comments

@pdxrlk
Copy link

pdxrlk commented Apr 16, 2024

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 pdxrlk added the 🐛 Bug [ISSUE] Ticket describing something that isn't working label Apr 16, 2024
@liss-bot
Copy link
Collaborator

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

@CrazyWolf13
Copy link
Collaborator

Linking this to #894

@CrazyWolf13 CrazyWolf13 self-assigned this Apr 16, 2024
@umolinar
Copy link

umolinar commented May 9, 2024

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

@liss-bot liss-bot added the 👤 Awaiting Maintainer Response [ISSUE] Response from repo author is pending label May 9, 2024
@Lissy93
Copy link
Owner

Lissy93 commented May 9, 2024

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.

@liss-bot liss-bot removed the 👤 Awaiting Maintainer Response [ISSUE] Response from repo author is pending label May 9, 2024
@CrazyWolf13 CrazyWolf13 removed their assignment May 9, 2024
@umolinar
Copy link

umolinar commented May 9, 2024 via email

@liss-bot liss-bot added the 👤 Awaiting Maintainer Response [ISSUE] Response from repo author is pending label May 9, 2024
@Lissy93
Copy link
Owner

Lissy93 commented May 9, 2024

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

@liss-bot liss-bot removed the 👤 Awaiting Maintainer Response [ISSUE] Response from repo author is pending label May 9, 2024
@umolinar
Copy link

umolinar commented May 9, 2024 via email

@liss-bot liss-bot added the 👤 Awaiting Maintainer Response [ISSUE] Response from repo author is pending label May 9, 2024
@CrazyWolf13
Copy link
Collaborator

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

@umolinar
Copy link

umolinar commented May 9, 2024 via email

@Lissy93
Copy link
Owner

Lissy93 commented May 10, 2024

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!! 🏖️😆

@liss-bot liss-bot removed the 👤 Awaiting Maintainer Response [ISSUE] Response from repo author is pending label May 10, 2024
@umolinar
Copy link

umolinar commented May 10, 2024 via email

@liss-bot liss-bot added the 👤 Awaiting Maintainer Response [ISSUE] Response from repo author is pending label May 10, 2024
@liss-bot liss-bot removed the 👤 Awaiting Maintainer Response [ISSUE] Response from repo author is pending label May 10, 2024
@umolinar
Copy link

umolinar commented May 10, 2024 via email

@CrazyWolf13
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug [ISSUE] Ticket describing something that isn't working
Projects
Status: Done
Development

No branches or pull requests

5 participants