Coder Social home page Coder Social logo

Comments (6)

KeshiaRose avatar KeshiaRose commented on June 9, 2024 1

Hi @GSapiah,

Honestly, that was news to me as well! I was thinking maybe I had just missed something in my code and realized the same behavior. I've opened a bug internally for our devs to take a look at it. Hopefully, they can shed some light on it and I'll report back here!

Internal: 925177

Take care,
Keshia

from extension-date-updater.

KeshiaRose avatar KeshiaRose commented on June 9, 2024

Thanks for the feedback @GSapiah! I've added a checkbox to adjust for time zone, can you try it out and let me know if it works for you? If it doesn't I'll re-open the issue.

Thanks,
Keshia

from extension-date-updater.

GSapiah avatar GSapiah commented on June 9, 2024

Thanks @KeshiaRose , I can see that you have changed the code as
date.setHours(date.getHours() - date.getTimezoneOffset()/60);

Observation
I had installed the previous project code locally and could see, in the console log, that new Date() was returning date in my local timezone and so did date.setDate(date.getDate() - 1); when yesterday was chosen. But the dashboard parameter was still showing the wrong date unless tz offset was subtracted similar to what you did in your new code.

Any idea why?

from extension-date-updater.

GSapiah avatar GSapiah commented on June 9, 2024

image

if (dashboardParameter.allowableValues.type === 'all' && (dashboardParameter.dataType === 'date' || dashboardParameter.dataType === 'date-time')) {
                    const parameter = parameters.find((p: any) => p.name === dashboardParameter.name);
                    console.log(parameter);
                    if (parameter) {
                        
                        const date = new Date();
                        console.log('Initialized : ' + date);
                        
                        const tzOffset = date.getTimezoneOffset();
                        console.log('Timezone Offset : ' + tzOffset);
                        
                        date.setMinutes(date.getMinutes() - tzOffset);
                        console.log('Including offset to date : ' + date);

                        switch (parameter.selectedDate) {
                            case Dates.Yesterday:
                                date.setDate(date.getDate() - 1);
                                break;
                            case Dates.SevenDaysAgo:
                                date.setDate(date.getDate() - 7);
                                break;
                            case Dates.ThirtyDaysAgo:
                                date.setDate(date.getDate() - 30);
                                break;
                        }
                        if (parameter.selectedDate !== Dates.None) {
                        	console.log('Selected : ' + date);
                        	dashboardParameter.changeValueAsync(date);
                        }
                    }

Attached is the debug code using console.log and the attached output.

Observations in the output image:

  1. When today is selected, the selected value is the future date but on the dashboard correct date is shown.

  2. similar as above, when yesterday is chosen dashboard shows the correct date even though selected date value is different.

from extension-date-updater.

KeshiaRose avatar KeshiaRose commented on June 9, 2024

Turns out we deliberately convert to UTC for consistency! Makes sense 😄, especially since parameters don't have a timezone associated with them. We'll be updating the documentation though to reflect that we do this conversion so folks are aware. Thanks for the feedback!

Take care,
Keshia

from extension-date-updater.

GSapiah avatar GSapiah commented on June 9, 2024

Hi @KeshiaRose ,
Thanks for confirming.

from extension-date-updater.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.