dashy
dashy copied to clipboard
[BUG] Public Holidays widget returns Invalid Date on Safari
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.
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
- [X] You have explained the issue clearly, and included all relevant info
- [X] You are using a supported version of Dashy
- [X] You've checked that this issue hasn't already been raised
- [X] You've checked the docs and troubleshooting guide
- [X] You agree to the code of conduct
If you're enjoying Dashy, consider dropping us a ⭐
🤖 I'm a bot, and this message was automated
Linking this to #894
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.
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.
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: @.***>
Hey @umolinar,
Thanks for the info. I just tested, but it seems to work okay for me using the below config
- type: public-holidays
options:
country: SV
holidayType: all
monthsToShow: 12
lang: en
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: @.***>
I can confirm on my iPad the dates do not show up.
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: @.***>
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!! 🏖️😆
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: @.***>
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: @.***>
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.