Home AMX User Forum AMX General Discussion

Clock Manager/AstrClock DST?

Does anyone know if I SET all the appropriate Clock Manager values as such:
CLKMGR_SET_CLK_SOURCE(CLKMGR_MODE_NETWORK) ; // or CLKMGR_MODE_STANDALONE
	  CLKMGR_SET_ACTIVE_TIMESERVER (CLKMGR_ACTIVESERVER) ;
	  CLKMGR_SET_TIMEZONE(CLKMGR_TIME_ZONE) ;
	  CLKMGR_SET_DAYLIGHTSAVINGS_MODE(TRUE) ;
	  CLKMGR_SET_START_DAYLIGHTSAVINGS_RULE("'occurrence:',itoa(DST_BEGINDAY_OCCURANCE),',',itoa(DST_BEGIN_DAY),',',itoa(DST_BEGIN_MONTH),',',DST_BEGIN_TIME" ) ;
	  CLKMGR_SET_END_DAYLIGHTSAVINGS_RULE("'occurrence:',itoa(DST_ENDDAY_OCCURANCE),',',itoa(DST_END_DAY),',',itoa(DST_END_MONTH),',',DST_END_TIME" ) ;
	  CLKMGR_SET_RESYNC_PERIOD(CLKMGR_RESYNC_PERIOD) ;
	  
	  sMyCLKMGR_TIMEOFFSET.HOURS   = CLKMGR_DST_OFFSET_HR ;
	  sMyCLKMGR_TIMEOFFSET.MINUTES = CLKMGR_DST_OFFSET_MIN ;
	  sMyCLKMGR_TIMEOFFSET.SECONDS = CLKMGR_DST_OFFSET_SEC ;
	  CLKMGR_SET_DAYLIGHTSAVINGS_OFFSET(sMyCLKMGR_TIMEOFFSET) ;
Assuming they're all set correctly and then call AstroClock:
ASTRO_CLOCK(CLKMGR_LAT,CLKMGR_LONG,CLKMGR_OFFSET_GMT,LDATE,sMyTime.cSunrise,sMyTime.cSunset);
Is this supposed to return the correct sunrise/sunset based on DST rules or do I need change CLKMGR_OFFSET_GMT which has a value of -5.0 to CLKMGR_OFFSET_EST (value -5.0) or CLKMGR_OFFSET_EDT (value -4.0) based on the return received from calling:
sGet_ClkMgr.nIs_DST_On = CLKMGR_IS_DAYLIGHTSAVINGS_ON();
I would think the clock manager would take care of that logic and I shouldn't have to call CLKMGR_IS_DAYLIGHTSAVINGS_ON() to determine if I should send EST or EDT in the ASTRO_CLOCK call but since my sunrise and sunset times are an hour behind maybe I need to.

The pic below shows the GET returns after values have been set to verify they have indeed been set.

Comments

  • Joe HebertJoe Hebert Posts: 2,159
    vining wrote:
    Does anyone know if I SET all the appropriate Clock Manager values as such...
    Assuming they're all set correctly and then call AstroClock
    Is this supposed to return the correct sunrise/sunset based on DST rules
    No, ASTRO_CLOCK will not return sunrise/sunset based on DST rules.
    vining wrote:
    I would think the clock manager would take care of that logic and I shouldn't have to call CLKMGR_IS_DAYLIGHTSAVINGS_ON() to determine if I should send EST or EDT
    The return value from CLKMGR_IS_DAYLIGHTSAVINGS_ON() does not tell you if DST is currently active; it only tells you whether Daylight Saving Time is observed. If you want to know if Daylight Saving Time is currently active then you need to make the calculation yourself based on the start and end rules. If DST is currently active then you’ll need to add one hour to sunrise and sunset calculated by ASTRO_CLOCK. (Unless you are doing a job in some place like Lord Howe Island, Australia where DST is only a 30 minute change – yikes)

    I know there have been several posts over the years asking for a simple flag to tell us if Daylight Saving Time is currently active but as far as I know no such built-in function exists.

    As an aside – Even though all the clock manager functions refer to it as Daylight Savings, the correct term is Daylight Saving.
  • viningvining Posts: 4,368
    Well that's odd, why would it care if DST is observed if it's not planning on doing anything about it and why bother sending it the start and end values if it isn't actually using them to perform any logic. What's it do with the values, just store them? They must have run out of funding when they were writing these functions. :)

    I already have a function to dertermine if DST is active that i can use to send either EST or EDT offset but i just assumed Is_dst_on would also give me that status but it looks like I'm wrong again.

    The docs don't don't really help any either. Thanks for the clarification.
  • truetrue Posts: 307
    A bit late, but the NCL has a function called clkmgr_is_daylightsavings_active() which performs these checks for you. It wasn't complete (only checks to the day, not the hour; returns 1/0 instead of the active offset) but it works. Wrote it long ago, maybe I should finally add these missing features ;)
  • Joe HebertJoe Hebert Posts: 2,159
    true wrote: »
    A bit late, but the NCL has a function called clkmgr_is_daylightsavings_active() which performs these checks for you. It wasn't complete (only checks to the day, not the hour; returns 1/0 instead of the active offset) but it works. Wrote it long ago, maybe I should finally add these missing features ;)

    I tried it long ago and it doesn’t work.

    This year in the USA, DST starts on Sunday March 10th and ends on Sunday November 3rd.

    Your function returns true for every day in March (March 1 – March 9 incorrect) and your function returns false for every day in November (November 1 and November 2 incorrect.)

    Thought you and whoever else might be using it should know.
  • ericmedleyericmedley Posts: 4,177
    This whole issue could be stopped if we all quit observing DST. ( I know... Wrong forum.)
  • truetrue Posts: 307
    Joe Hebert wrote: »
    I tried it long ago and it doesn’t work.

    This year in the USA, DST starts on Sunday March 10th and ends on Sunday November 3rd.

    Your function returns true for every day in March (March 1 – March 9 incorrect) and your function returns false for every day in November (November 1 and November 2 incorrect.)

    Thought you and whoever else might be using it should know.

    Then yes, this is a bug and really needs fixed, I will look into it. thanks =)
  • viningvining Posts: 4,368
    true wrote:
    true
    A bit late, but the NCL has a function called clkmgr_is_daylightsavings_active() which performs these checks for you. It wasn't complete (only checks to the day, not the hour; returns 1/0 instead of the active offset) but it works. Wrote it long ago, maybe I should finally add these missing features
    I already had a function in my Date & Time .axi that would check for for the DST state but I wasn't using it since I erroneously assumed it was being handle by the built in functions. I still want to know why they ask for the info if they aren't using it.

    I attached my include file and if anyone wants to use it there are some function calls that need to be commented out or the functions created in your main code. Basically just calls from the Date and Time inlcude to run events based on time that I run in the main since I don't want them placed in the include file. Every Second, Minute, Hour, Daily type of crap.
Sign In or Register to comment.