DAY_OF_WEEK (DATE)

John_GloveJohn_Glove Junior MemberPosts: 95
hi

for tracking event's only on several day's, i take the following cmd: DAY_OF_WEEK (DATE) put it on a sinteger.
that works fine with a button_event or in the startup.
but i want refresh the variable every night on 12pm. so there is a channel_event every night on the same time. the channel_event works every night, but the following cmd doesn't seem to work in this channel_event:

nDay = DAY_OF_WEEK (DATE)

the variable doesn't change.

any hint's?

thanks
john

Comments

  • DHawthorneDHawthorne Junior Member Posts: 4,584
    Couple things. Maybe you just mistyped, but 12pm is noon, not midnight. In fact, there is a debate that AM and PM are meaningless at 12, and you should always call it noon or midnight ... but in your AMX master, 12 is noon, and 00 is midnight. Second, I'm pretty sure you want your channel to be at 00:01. I do not believe the new day starts until after 12, not exactly at 12. Third, double check the scope of your variable. If it's defined in the event, or if you simplified for the forums and there are other re-assignemts in there, make sure whatever variable you are sticking the result in has a scope outside the event. Once the event has passed, it's going to be meaningless if defined inside the event as stack.
  • GregGGregG Just some guy... Posts: 249
    I usually run a checking timeline every minute to update things that don't change very often. And instead of waiting for the channel event, you could just put the code you need to execute on certain days into the checking timeline itself:
    DEFINE_CONSTANT
    
    TL_CHECK_DOW_CHANGE = 2
    
    DEFINE_VARIABLE
    
    Volatile Long lTimes[1]
    Persistent Integer nDayOfWeek
    
    DEFINE_START
    
    lTimes[1] = 60000 // Every 60 seconds
    Timeline_Create(TL_CHECK_DOW_CHANGE,lTimes,1,TIMELINE_RELATIVE,TIMELINE_REPEAT)
    
    DEFINE_EVENT
    
    Timeline_Event[TL_CHECK_DOW_CHANGE]
    {
      // Use this "If" to determine the first time we find a new day
      If(nDayOfWeek <> DATE_TO_DAY(DATE))
      {
          FunctionToPerformThingsOnCertainDays( DAY_OF_WEEK(DATE) )
      }
      // Just use this to only update the day variable
      nDayOfWeek = DAY_OF_WEEK(DATE)
    }
    
  • John_GloveJohn_Glove Junior Member Posts: 95
    hi all

    thanks for the replies.

    first, sorry i mean midnight correct :-)
    my channel_event works on midnight every night. i do this with (COMPARE_STRING(TIME,'00:05:0?'))
    my problem is in the ON event of the channel_event the cmd:

    nDay = DAY_OF_WEEK (DATE)

    doesn't be updatet. all other cmd in this event works.

    example:

    CHANNEL_EVENT[vdv__EVENT,003]
    {
    ON:
    {
    nDAY = DAY_OF_WEEK (DATE)

    }
    }
  • GregGGregG Just some guy... Posts: 249
    Have you tried putting a line like this in the channel event after your assignment to see what it tells you:
    CHANNEL_EVENT[vdv__EVENT,003] 
    {
    ON:
    {
    nDAY = DAY_OF_WEEK (DATE) 
    Send_String 0,"'nDAY=',Itoa(nDAY),' DAY_OF_WEEK(DATE)=',Itoa(DAY_OF_WEEK(DATE))"
    }
    }
    

    This could help you determine if something else in your code is making changes that you didn't expect.
  • viningvining X Member Posts: 4,341
    I use a date & time.axi that runs on a 250ms repeating timeline that always runs and so that everything is always available. There are some things declared in my constants.axi or in my main.axs but it's should be pretty apparent what the functions are for and you can comment out as you need and create your own code to utilize some of the calls.

    Here's the axi code, use all, part or none as you see fit.
    PROGRAM_NAME='VAV_Date_&_Time'
    
    DEFINE_CONSTANT //DST                           <<<*************************  CHANGE SETTING PER JOB *********************************>>>
    //Typically clocks are adjusted forward one hour near the start of spring and are adjusted backward in autumn.[1] 
    //Starting in 2007, Daylight Saving Time (DTS) has been extended by one month. Therefore, the start date of DTS in the United States has been
    //changed to the 2nd Sunday in March and the end date of DTS has been changed to the 1st Sunday in November
    
    //If Daylight Savings Time is currently being observed (between spring and fall), set this item to "1". If Daylight Savings Time
    //is not currently being observed (between fall and spring) or is not observed in your geographic location, set this item to "0".
    //This item is used to correctly calculate the times for sunrise and sunset.
    
    INTEGER DST_OBSERVED		= 1;  		//1 for yes and 0 for no 
    INTEGER DST_OFFSET		= 1;  		//number of hours time is offset 
    INTEGER DST_BEGIN_MONTH		= 3;  		//March (months 1-12 January to December)
    INTEGER DST_END_MONTH		= 11; 		//November (months 1-12 January to December)
    INTEGER DST_BEGIN_DAY		= 1;  		//Sunday (day of week 1-7 Sunday to Saturday)
    INTEGER DST_END_DAY		= 1;  		//Sunday (day of week 1-7 Sunday to Saturday)
    INTEGER DST_BEGINDAY_OCCURANCE	= 2;  		//Number of occurances of that day in that month (2nd Sunday)
    INTEGER DST_ENDDAY_OCCURANCE	= 1;  		//Number of occurances of that day in that month (1st Sunday)
    CHAR DST_BEGIN_TIME[]		= '02:00:00';	//Time change occurs 
    CHAR DST_END_TIME[]		= '02:00:00';	//Time change occurs 
    
    DEFINE_CONSTANT //ASTRO_CLOCK LAT/LONG          <<<*************************  CHANGE SETTING PER JOB *********************************>>>
    
    INTEGER CLKMGR_DST		= 1;     	//1 for ON and 0 for OFF
    INTEGER CLKMGR_DST_OFFSET_HR	= 1;     	//1 for 1 hour
    INTEGER CLKMGR_DST_OFFSET_MIN	= 0;     	//0 for 0 minutes
    INTEGER CLKMGR_DST_OFFSET_SEC	= 0;     	//0 for 0 seconds
    INTEGER CLKMGR_RESYNC_PERIOD	= 240;     	//in minutes 480 = 8 hours, choices: 5 min, 15 min, 2 hour, 4 hours & (8 hours?)
    					        //the web interface doesn't show an 8 hour option but the keyword example only shows
    					        //an hour hour example. So I choose the highest the web gui lists 4 hours/240 minutes. 
    
    DOUBLE CLKMGR_LAT		= -73.42;	//Longitude - Longitude in Degrees.Fraction of Degrees. West longitudes must be negative.
    DOUBLE CLKMGR_LONG		= 41.98; 	//Latitude - Latitude in Degrees.Fraction of Degrees. South latitudes must be negative 
    DOUBLE CLKMGR_OFFSET_GMT_EST	= -5.0;  	//HoursFromGMT - Number of hours from GMT. Hours West of GMT can be entered as 
    DOUBLE CLKMGR_OFFSET_GMT_EDT	= -4.0;  	//HoursFromGMT - Number of hours from GMT. Hours West of GMT can be entered as 
    
    CHAR CLKMGR_TIME_ZONE[]		= 'UTC-05:00';	//Input string must have the correct format: UTC[+|-]HH:MM
    CHAR CLKMGR_ACTIVESERVER[] 	= '132.163.4.101'; 
    
    DEFINE_CONSTANT //TIME CONSTANTS Days of Week & Month of Year
    
    SUNDAY        	= 1;
    MONDAY        	= 2;
    TUESDAY       	= 3;
    WEDNESDAY     	= 4;
    THURSDAY      	= 5;
    FRIDAY        	= 6;
    SATURDAY      	= 7;
    
    JANUARY		= 1;
    FEBRUARY	= 2;
    MARCH		= 3;
    APRIL		= 4;
    MAY		= 5;
    JUNE		= 6;
    JULY 		= 7;
    AUGUST		= 8;
    SEPTEMBER	= 9;
    OCTOBER		= 10;
    NOVEMBER	= 11;
    DECEMBER	= 12;
    
    FIRST           = 1;
    SECOND          = 2;
    THIRD           = 3;
    FOURTH          = 4;
    FIFTH           = 5;
    
    EXPIRES_IN_SECONDS      	= 10; 
    INTEGER NUM_SECONDS_MINUTE	= 60;
    INTEGER NUM_SECONDS_30MIN	= 1800;
    INTEGER NUM_SECONDS_HOUR	= 3600;
    LONG NUM_SECONDS_DAY	    	= 86400;
    
    INTEGER NUM_MINUTES_HOUR	= 60;
    INTEGER NUM_MINUTES_DAY		= 1440;
    
    CHAR DAY_OF_WEEK_ABREV[7][3]   = {'SUN','MON','TUE','WED','THU','FRI','SAT'}
    CHAR DAY_OF_WEEK_FULL[7][9]    = {'Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'}
    
    CHAR MONTH_OF_YR_ABREV[12][3]   = {'Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'}; 
    CHAR MONTH_OF_YR_FULL[12][9]    = {'January','February','March','April','May','June','July','August','September','October','November','December'}; 
    CHAR DAYS_MONTHs[12]        	= {31   ,28   ,31   ,30   ,31   ,30   ,31   ,31   ,30   ,31   ,30   ,31};
    CHAR DAYS_LEAPMONTHs[12]    	= {31   ,29   ,31   ,30   ,31   ,30   ,31   ,31   ,30   ,31   ,30   ,31};
    
    DEFINE_CONSTANT //UI FEEDBACK EVENTS
    
    FB_TIME_TIME       	= 1;
    FB_TIME_SUNRISE		= 2;
    FB_TIME_SUNSET		= 3;
    FB_TIME_DST		= 4;
    FB_TIME_HOLIDAY		= 5;
    
    DEFINE_TYPE     //TIME STUFF
    
    STRUCTURE _sMyTime
    
         {
         INTEGER 	nYear;
         INTEGER 	nMonth;
         INTEGER 	n24Hour;
         INTEGER 	n12Hour;
         INTEGER 	nMinute;
         INTEGER 	nSecond;
         INTEGER 	nDayOfMonth;
         INTEGER 	nDayOfWeek;
         INTEGER  	nDayOccurance[7];
         LONG	nTime_Seconds;
         LONG	nTime_Minutes;
         CHAR	c24Time[8];
         CHAR	c12Time[8];
         INTEGER 	nWeekOfMonth;
         INTEGER 	nPlusDays;
         INTEGER 	nDaytime;
         INTEGER    nTimePM_flag;
         CHAR       cAMPM[2];
         LONG     	nSunriseTime;
         LONG     	nSunSetTime;
         CHAR 	cSunrise[10];
         CHAR 	cSunset[10];
         INTEGER 	nSunset24Hour;
         INTEGER 	nSunset12Hour;
         INTEGER 	nSunsetMinute;
         INTEGER 	nSunsetSecond;
         INTEGER 	nSunriseHour;
         INTEGER 	nSunriseMinute;
         INTEGER 	nSunriseSecond;
         CHAR     	cHoliday[24];
         CHAR     	cDay[3];
         CHAR     	cDate[8];
         CHAR 	cWebCurDateTime[29];
         CHAR 	cWebExpDateTime[29];
         }
         
    DEFINE_TYPE     //DST
    
    STRUCTURE _sMyDST
    
         {
         INTEGER nDST_Active;
         INTEGER nOffset;
         INTEGER nObserved;
         INTEGER nBEG_Month;
         INTEGER nEND_Month;
         INTEGER nBEG_Day;
         INTEGER nEND_Day;
         INTEGER nBEG_DAY_Occurance;
         INTEGER nEND_DAY_Occurance;
         }
         
    DEFINE_TYPE 	//_sGet_ClkMgr
    
    STRUCTURE _sGet_ClkMgr
         {
         INTEGER nReSyncPeriod;
         INTEGER nIs_DST_On;
         CHAR cTimeZone[9];
         CHAR cDST_StartRule[128];
         CHAR cDST_EndRule[128];
         CLKMGR_TIMESERVER_STRUCT sActiveTimeServer;
         CLKMGR_TIMEOFFSET_STRUCT sOffset;
         CLKMGR_TIMESERVER_STRUCT sTimeServers[4];
         }
    
    DEFINE_TYPE     //CLKMGR_TIMEOFFSET_STRUCT FROM NETLINX.AXI FOR REFERNCE ONLY
    
    (*    
    STRUCTURE CLKMGR_TIMEOFFSET_STRUCT
         
         {
         INTEGER     HOURS;
         INTEGER     MINUTES;
         INTEGER     SECONDS;
         }
    *)
    
    DEFINE_VARIABLE //STRUCTURES
    
    PERSISTENT _sMyTime sMyTime;
    VOLATILE   _sMyDST sMyDST;
    VOLATILE   _sGet_ClkMgr sGet_ClkMgr;//just holds the get queries
    
    VOLATILE INTEGER nTimeWait_Force = 1;
    VOLATILE INTEGER nTime_DeBug = 1;
    
    DEFINE_VARIABLE //TIMELINE
    
    VOLATILE LONG nTL_TIME_RT[] = {250};
    
    DEFINE_FUNCTION LONG fnConv_24HrTimeToSeconds(CHAR iTime[])
    
         {
         RETURN ((((ATOI(REMOVE_STRING(iTime,"':'",1)) * 60) + ATOI(REMOVE_STRING(iTime,"':'",1))) * 60) + ATOI(iTime));
         }
         
    DEFINE_FUNCTION CHAR[8] fnConv_SecondsTo24HrTime(LONG iTimeInSeconds)
    
         {
         RETURN   "right_string("'0',ITOA(iTimeInSeconds / 3600)",2),':',
    		    right_string("'0',ITOA((iTimeInSeconds % 3600) / 60)",2),':',
    			 right_string("'0',ITOA((iTimeInSeconds % 3600) % 60)",2)";
         }
         
    DEFINE_FUNCTION CHAR[30] fnDo_24hrTimeAddition(CHAR iLDate[],CHAR i24HourTime[],LONG iSecondsAdded)     
         
         {
         STACK_VAR INTEGER nYear;       //change to all stack_var's
         STACK_VAR INTEGER nMonth;
         STACK_VAR INTEGER nLeap;
         STACK_VAR CHAR c24HrTime[8];
         STACK_VAR CHAR cNewDate[10];
         STACK_VAR LONG nDay;
         STACK_VAR LONG nDaysOver;
         STACK_VAR LONG nSecondsRemain;
         STACK_VAR LONG nTotalTimeSeconds;
         
         nTotalTimeSeconds = fnConv_24HrTimeToSeconds(i24HourTime) + iSecondsAdded;
         nMonth = atoi("REMOVE_STRING(iLDATE,"'/'",1)");
         nDay   = atoi("REMOVE_STRING(iLDATE,"'/'",1)");
         nYear  = atoi("iLDATE");
         
         if(nTotalTimeSeconds > NUM_SECONDS_DAY)
    	  {
    	  STACK_VAR INTEGER i;
    	  
    	  nDaysOver = nTotalTimeSeconds / NUM_SECONDS_DAY;
    	  nSecondsRemain = nTotalTimeSeconds % NUM_SECONDS_DAY;
    	  if(!(nYear % 4))//http://en.wikipedia.org/wiki/Leap_year
    	       {
    	       nLeap = 1;
    	       if(!(nYear % 100))//double check these rules?????? 
    		    {
    		    if(nYear % 400)
    			 {
    			 nLeap = 0;
    			 }
    		    }
    	       }
    	  if(nLeap)
    	       {
    	       if((nDaysOver + nDay) > DAYS_LEAPMONTHs[nMonth])
    		    {
    		    nDaysOver = nDaysOver - (DAYS_LEAPMONTHs[nMonth] - nDay);
    		    nMonth++;
    		    
    		    for(nMonth = nMonth; nDaysOver > DAYS_LEAPMONTHs[nMonth]; nMonth++)
    			 {
    			 nDaysOver = (nDaysOver - DAYS_LEAPMONTHs[nMonth]);
    			 if(nMonth == 12)
    			      {
    			      nMonth = 1;
    			      nYear ++;
    			      }
    			 }
    		    nDay = nDaysOver;
    		    }
    	       else
    		    {
    		    nDay = nDaysOver + nDay;
    		    }
    	       }
    	  else
    	       {
    	       if((nDaysOver + nDay) > DAYS_MONTHs[nMonth])
    		    {
    		    nDaysOver = nDaysOver - (DAYS_MONTHs[nMonth] - nDay);
    		    nMonth++;
    		    
    		   for(nMonth = nMonth; nDaysOver > DAYS_MONTHs[nMonth]; nMonth++)
    			 {
    			 nDaysOver = (nDaysOver - DAYS_MONTHs[nMonth]);
    			 if(nMonth == 12)
    			      {
    			      nMonth = 1;
    			      nYear ++;
    			      }
    			 }
    		    nDay = nDaysOver;
    		    }
    	       else
    		    {
    		    nDay = nDaysOver + nDay;
    		    }
    	       }
    	  c24HrTime = fnConv_SecondsTo24HrTime(nSecondsRemain); 
    	  }
         else
    	  {
    	  c24HrTime = fnConv_SecondsTo24HrTime(nTotalTimeSeconds);
    	  }
         cNewDate = "right_string("'0',ITOA(nMonth)",2),'/',right_string("'0',ITOA(nDay)",2),'/',right_string("'0',ITOA(nYear)",2)";
    	   
         RETURN "DAY_OF_WEEK_ABREV[TYPE_CAST(DAY_OF_WEEK(cNewDate))],', ',itoa(nDay),' ',MONTH_OF_YR_ABREV[nMonth],' ',itoa(nYear),' ',c24HrTime";
         }
         
    DEFINE_FUNCTION fnFB_Time(INTEGER iUI_Indx,INTEGER iEvent) //<< SET VT ADDRESS CHANNELS  CHANGE SETTING PER JOB **********************>>>
    
         {
         SWITCH(iEvent)
    	  {
    	  CASE FB_TIME_TIME:
    	       {
    	       //panels can handle time on their own 
    	       }
    	  CASE FB_TIME_SUNRISE:
    	       {
    	       fnFB_TimeSend_VT(iUI_Indx,BTN_VT_SUNRISE,"'Sunrise at ',itoa(sMyTime.nSunriseHour),':',itoa(sMyTime.nSunriseMinute),' AM'");
    	       }
    	  CASE FB_TIME_SUNSET:
    	       {
    	       fnFB_TimeSend_VT(iUI_Indx,BTN_VT_SUNSET,"'Sunset at ',itoa(sMyTime.nSunset12Hour),':',itoa(sMyTime.nSunsetMinute),' PM'");
    	       }
    	  CASE FB_TIME_DST:
    	       {
    	       if(sMyDST.nDST_Active)
    		    {
    		    //fnFB_TimeSend_VT(iUI_Indx,??,"'DST: IN EFFECT'"); 
    		    }
    	       else
    		    {
    		    //fnFB_TimeSend_VT(iUI_Indx,??,"'DST: NOT IN EFFECT'"); 
    		    }
    	       }
    	  CASE FB_TIME_HOLIDAY:
    	       {
    	       fnFB_TimeSend_VT(iUI_Indx,BTN_VT_HOLIDAY,"sMyTime.cHoliday");
    	       }
    	  }
         }
         
    DEFINE_FUNCTION fnFB_TimeSend_VT(INTEGER iUI_Indx,INTEGER iCHAN,CHAR iStrMSG[500]) 
         
         {
         STACK_VAR INTEGER n;
         STACK_VAR INTEGER nTPCount; 
         STACK_VAR INTEGER nLoopStart; 
         
         if(iUI_Indx)
    	  {
    	  nTPCount = iUI_Indx;
    	  nLoopStart = iUI_Indx;
    	  }
         else
    	  {
    	  nTPCount = NUM_UIs_IN_SYSTEM;
    	  nLoopStart = 1;
    	  }
    	  
         //fnTime_DeBug("'SEND_VT: ',iStrMSG,' :DEBUG <',itoa(__LINE__),'>'");
         
         for(n = nLoopStart; n <= nTPCount; n++)
    	  {
    	  SWITCH(nUI_TypeArry[n])
    	       {
    	       CASE UI_TYPE_G4:
    	       CASE UI_TYPE_R4:
    	       CASE UI_TYPE_MIO_DMS:
    	       (* no need for uni strings!!!
    		    {
    		    STACK_VAR WIDECHAR cSTRING1[500];
    		    STACK_VAR CHAR cSTRING2[500];
    		    
    		    cSTRING1 = WC_DECODE(iStrMSG,WC_FORMAT_UTF8,1); 
    		    cSTRING2 = WC_ENCODE(cSTRING1,WC_FORMAT_TP,1);
    		    //fnTime_DeBug("'^UNI- TP INDX: ',itoa(n),', CHNL: ',itoa(iCHAN),' :DEBUG <',ITOA(__LINE__),'>'");
    		    SEND_COMMAND dvUI_Arry[n], "'^UNI-',itoa(iCHAN),',0,',cSTRING2"; 
    		    }
    	       *)
    	       CASE UI_TYPE_G3:
    	       CASE UI_TYPE_iPHONE://uni not supported yet		
    	       CASE UI_TYPE_iPAD:		
    	       CASE UI_TYPE_iTOUCH:	
    		    {
    		    //fnTime_DeBug("'^TXT- TP INDX: ',itoa(n),', CHNL: ',itoa(iCHAN),' :DEBUG <',ITOA(__LINE__),'>'");
    		    SEND_COMMAND dvUI_Arry[n], "'TEXT',itoa(iCHAN),'-',iStrMSG"; 
    		    }
    	       CASE UI_TYPE_METKP:
    	       CASE UI_TYPE_UNKNOWN:
    	       CASE UI_TYPE_VIRTUAL:
    		    {
    		    //DO NOTHING
    		    }
    	       }
    	  }
    	  
         RETURN;
         }
    
    DEFINE_FUNCTION fnTime_DeBug(CHAR iStr[])
    
         {
         if(nTime_DeBug)
    	  {
    	  STACK_VAR CHAR cCopyStr[1024];
    	  STACK_VAR INTEGER nLineCount;
    	  
    	  cCopyStr = iStr;
    	  
    	  nLineCount ++;
    	  WHILE(length_string(cCopyStr) > 100)
    	       {
    	       SEND_STRING 0,"'TIME DEBUG (',itoa(nLineCount),'): ',get_buffer_string(cCopyStr,100)";
    	       nLineCount ++;
    	       }
    	  if(length_string(cCopyStr))
    	       {
    	       SEND_STRING 0,"'TIME DEBUG (',itoa(nLineCount),'): ',cCopyStr";
    	       }
    	  }
         
         RETURN;
         } 
         
    DEFINE_FUNCTION fnGet_DST_State() 
         
         {//don't care about the hour of day it actually occurs!
         fnTime_DeBug("'fnCheckDST_Rule(): Checking DST State :DEBUG <',ITOA(__LINE__),'>'");
         SELECT
    	  {
    	  ACTIVE(sMyTime.nMonth < DST_BEGIN_MONTH || sMyTime.nMonth > DST_END_MONTH):
    	       {//quick elimination
    	       sMyDST.nDST_Active = 0;
    	       }
    	  ACTIVE(sMyTime.nMonth > DST_BEGIN_MONTH && sMyTime.nMonth < DST_END_MONTH):
    	       {//quick elimination
    	       sMyDST.nDST_Active = 1;
    	       }
    	  ACTIVE(sMyTime.nMonth == DST_BEGIN_MONTH): 
    	       {
    	       if(sMyTime.nDayOccurance[sMyDST.nBEG_Day] >= sMyDST.nBEG_DAY_Occurance)
    		    {
    		    sMyDST.nDST_Active = 1;
    		    }
    	       else
    		    {
    		    sMyDST.nDST_Active = 0;
    		    }
    	       }
    	  ACTIVE(sMyTime.nMonth == DST_END_MONTH): 
    	       {
    	       if(sMyTime.nDayOccurance[sMyDST.nEND_Day] >= sMyDST.nEND_DAY_Occurance)
    		    {
    		    sMyDST.nDST_Active = 0;
    		    }
    	       else
    		    {
    		    sMyDST.nDST_Active = 1;
    		    }
    	       }
    	  ACTIVE(TRUE):
    	       {
    	       fnTime_DeBug("'fnCheckDST_Rule(): DST Check Error! :DEBUG <',ITOA(__LINE__),'>'");
    	       
    	       RETURN;
    	       }
    	  } 
         if(sMyDST.nDST_Active)
    	  {
    	  fnTime_DeBug("'fnCheckDST_Rule(): DST is Active! :DEBUG <',ITOA(__LINE__),'>'");
    	  }
         else
    	  {
    	  fnTime_DeBug("'fnCheckDST_Rule(): DST is In-Active! :DEBUG <',ITOA(__LINE__),'>'");
    	  }
    	  
         fnFB_Time(UI_UPDATE_ACTIVE,FB_TIME_DST);
    	  
         RETURN;
         }
         
    DEFINE_FUNCTION fnGet_AstroClock()
    
         {
         LOCAL_VAR SINTEGER nTimeMngr_Result;
             
         fnTime_DeBug("'fnAstro_Clock(): Running ArtoClock! :DEBUG <',ITOA(__LINE__),'>'");
        
         sGet_ClkMgr.cTimeZone = CLKMGR_GET_TIMEZONE();
         sGet_ClkMgr.nReSyncPeriod = CLKMGR_GET_RESYNC_PERIOD();
         sGet_ClkMgr.nIs_DST_On = CLKMGR_IS_DAYLIGHTSAVINGS_ON();// this only return whether it's observed or not not if it's active, very stupid!
         sGet_ClkMgr.cDST_EndRule = CLKMGR_GET_END_DAYLIGHTSAVINGS_RULE();
         sGet_ClkMgr.cDST_StartRule = CLKMGR_GET_START_DAYLIGHTSAVINGS_RULE();
         CLKMGR_GET_TIMESERVERS(sGet_ClkMgr.sTimeServers);
         CLKMGR_GET_DAYLIGHTSAVINGS_OFFSET(sGet_ClkMgr.sOffset);
         CLKMGR_GET_ACTIVE_TIMESERVER(sGet_ClkMgr.sActiveTimeServer);
        
         if(sMyDST.nObserved)
    	  {
    	  fnGet_DST_State();
    	  }
         
         //SINTEGER ASTRO_CLOCK(DOUBLE Longitude,DOUBLE Latitude,DOUBLE HoursFromGMT,CHAR[] Date,CHAR[] Sunrise,CHAR[] Sunset)
         
         if(sMyDST.nDST_Active)//
    	  {
    	  nTimeMngr_Result = ASTRO_CLOCK(CLKMGR_LAT,CLKMGR_LONG,CLKMGR_OFFSET_GMT_EDT,LDATE,sMyTime.cSunrise,sMyTime.cSunset);
    	  }
         else
    	  {
    	  nTimeMngr_Result = ASTRO_CLOCK(CLKMGR_LAT,CLKMGR_LONG,CLKMGR_OFFSET_GMT_EST,LDATE,sMyTime.cSunrise,sMyTime.cSunset);
    	  }
             
         fnTime_DeBug("'fnAstro_Clock(): Sunset Time = ',sMyTime.cSunset,' :DEBUG <',ITOA(__LINE__),'>'");
         sMyTime.nSunset24Hour = atoi(left_string(sMyTime.cSunset,2));
         sMyTime.nSunsetMinute = atoi(mid_string(sMyTime.cSunset,4,2));
         sMyTime.nSunsetSecond = atoi(right_string(sMyTime.cSunset,2));
         sMyTime.nSunsetTime   =  ((((sMyTime.nSunset24Hour * 60) + sMyTime.nSunsetMinute) * 60) + sMyTime.nSunsetSecond);
         if(sMyTime.nSunset24Hour >= 12)
              {
    	  sMyTime.nSunset12Hour = sMyTime.nSunset24Hour - 12;
    	  }
         else//yeah, I know!
    	  {
    	  sMyTime.nSunset12Hour = sMyTime.nSunset24Hour;
    	  }
         fnTime_DeBug("'fnAstro_Clock(): Sunrise Time = ',sMyTime.cSunrise,' :DEBUG <',ITOA(__LINE__),'>'");
         sMyTime.nSunriseHour   = atoi(left_string(sMyTime.cSunrise,2));
         sMyTime.nSunriseMinute = atoi(mid_string(sMyTime.cSunrise,4,2));
         sMyTime.nSunriseSecond = atoi(right_string(sMyTime.cSunrise,2));
         sMyTime.nSunriseTime   = ((((sMyTime.nSunriseHour * 60) + sMyTime.nSunriseMinute) * 60) + sMyTime.nSunriseSecond);
         fnFB_Time(UI_UPDATE_ACTIVE,FB_TIME_SUNRISE);
         fnFB_Time(UI_UPDATE_ACTIVE,FB_TIME_SUNSET);
         }
         
    DEFINE_FUNCTION fnGet_DayOccurrences()
    
         {
         if(sMyTime.nDayOfWeek && sMyTime.nDayOfMonth)
    	  {
    	  STACK_VAR INTEGER i;
    	  STACK_VAR INTEGER nD_O_W;
    	  
    	  sMyTime.nWeekOfMonth = sMyTime.nDayOfMonth / 7;
    	  sMyTime.nPlusDays  = sMyTime.nDayOfMonth % 7;
    	  
    	  for(i = 1; i <= 7; i ++)//first erase stored values 
    	       {
    	       sMyTime.nDayOccurance[i] = 0;
    	       }
    	
    	  nD_O_W = sMyTime.nDayOfWeek;
    	  sMyTime.nDayOccurance[nD_O_W] ++;
    	  
    	  for(i = sMyTime.nDayOfMonth; i > 1; i --)
    	       {
    	       if(nD_O_W > 1) 
    		    {
    		    nD_O_W --;
    		    }		    
    	       else 
    		    {
    		    nD_O_W = 7;
    		    }
    	       sMyTime.nDayOccurance[nD_O_W] ++;
    	       }
    	  fnTime_DeBug("'fnFindDayOccurences(): The First Day of the Month= ',DAY_OF_WEEK_ABREV[nD_O_W],' (',itoa(nD_O_W),') :DEBUG <',ITOA(__LINE__),'>'");
    	  fnTime_DeBug("'fnFindDayOccurences(): Weeks= ',itoa(sMyTime.nWeekOfMonth),', Days= ',itoa(sMyTime.nPlusDays),
    			 ', Day= ',itoa((sMyTime.nWeekOfMonth * 7) + sMyTime.nPlusDays),' of ',MONTH_OF_YR_ABREV[sMyTime.nMonth],' :DEBUG <',ITOA(__LINE__),'>'");
    
    	  }
         else
    	  {
    	  fnTime_DeBug("'fnFindDayOccurences(): Error! No Value in sMyTime.nDayOfWeek or sMyTime.nDayOfMonth :DEBUG <',ITOA(__LINE__),'>'");
    	  }
         }
         
    DEFINE_FUNCTION fnGet_Holiday()
    
         {
         sMyTime.cHoliday = '';
         
         SWITCH(sMyTime.nMonth)
    	  {
    	  CASE JANUARY:
    	       {
    	       SELECT
    		    {
    		    ACTIVE(sMyTime.nDayOfMonth == 1):
    			 {
    			 sMyTime.cHoliday = 'New Years Day';
    			 }
    		    ACTIVE(sMyTime.nDayOccurance[MONDAY] == THIRD && sMyTime.nDayOfWeek == MONDAY):
    			 {
    			 sMyTime.cHoliday = "'M.L.King',39,'s Birthday'";
    			 }
    		    }
    	       }
    	  CASE FEBRUARY:
    	       {
    	       SELECT
    		    {
    		    ACTIVE(sMyTime.nDayOfMonth == 2):
    			 {
    			 sMyTime.cHoliday = 'Ground Hog Day';
    			 }
    		    ACTIVE(sMyTime.nDayOfMonth == 14):
    			 {
    			 sMyTime.cHoliday = "'Valentine',39,'s Day'";
    			 }
    		    ACTIVE(sMyTime.nDayOfMonth == 22):
    			 {
    			 sMyTime.cHoliday = "'G. Washington',39,'s Birthday'";
    			 }
    		    ACTIVE(sMyTime.nDayOccurance[MONDAY] == THIRD && sMyTime.nDayOfWeek == MONDAY):
    			 {
    			 sMyTime.cHoliday = "'President',39,'s Day'";
    			 }
    		    }
    	       }
    	  CASE MARCH:
    	       {
    	       SELECT
    		    {
    		    ACTIVE(sMyTime.nDayOfMonth == 9):
    			 {
    			 sMyTime.cHoliday = "'Employee Appreciation Day'";
    			 }
    		    //ACTIVE(sMyTime.nDayOfMonth >= 10 && sMyTime.nDayOfMonth < 14):
    //			 {
    //			 sMyTime.cHoliday = "'Aniversary in ',itoa(14-sMyTime.nDayOfMonth),' days'";
    //			 }
    //		    ACTIVE(sMyTime.nDayOfMonth >= 10 && sMyTime.nDayOfMonth < 14):
    //			 {
    //			 sMyTime.cHoliday = "'Steve & Jojo''s ',itoa(sMyTime.nYear - 1984),'th Aniversary!'";
    //			 }
    		    ACTIVE(sMyTime.nDayOfMonth == 17):
    			 {
    			 sMyTime.cHoliday = "'ST Patrick',39,'s Day'";
    			 }
    		    }
    	       //EASTER?
    	       }
    	  CASE APRIL:
    	       {
    	       SELECT
    		    {
    		    ACTIVE(sMyTime.nDayOfMonth == 1):
    			 {
    			 sMyTime.cHoliday = "'April Fool',39,'s Day'";
    			 }
    		    ACTIVE(sMyTime.nDayOfMonth == 14):
    			 {
    			 sMyTime.cHoliday = "'Valentine',39,'s Day'";
    			 }
    		    ACTIVE(sMyTime.nDayOccurance[MONDAY] == THIRD && sMyTime.nDayOfWeek == MONDAY):
    			 {
    			 sMyTime.cHoliday = "'Patriot',39,'s Day'";
    			 }
    		    }
    	       }
    	  CASE MAY:
    	       {
    	       SELECT
    		    {
    		    ACTIVE(sMyTime.nDayOfMonth >= 1 && sMyTime.nDayOfMonth < 5):
    			 {
    			 sMyTime.cHoliday = "'Martha''s birthday in ',itoa(5-sMyTime.nDayOfMonth),' days'";
    			 }
    		    ACTIVE(sMyTime.nDayOfMonth >= 10 && sMyTime.nDayOfMonth < 14):
    			 {
    			 sMyTime.cHoliday = "'Martha''s birthday!'";
    			 }
    		    ACTIVE(sMyTime.nDayOccurance[SUNDAY] == SECOND && sMyTime.nDayOfWeek == SUNDAY):
    			 {
    			 sMyTime.cHoliday = "'Mother''s Day'";
    			 }
    		    ACTIVE(sMyTime.nDayOccurance[SATURDAY] == THIRD && sMyTime.nDayOfWeek == SATURDAY):
    			 {
    			 sMyTime.cHoliday = "'Armed Forces Day'";
    			 }
    		    ACTIVE(sMyTime.nDayOccurance[MONDAY] == FOURTH && sMyTime.nDayOfMonth > 24 && sMyTime.nDayOfWeek == MONDAY):
    			 {
    			 sMyTime.cHoliday = 'Memorial Day';
    			 }
    		    ACTIVE(sMyTime.nDayOccurance[MONDAY] == FIFTH && sMyTime.nDayOfWeek == MONDAY):
    			 {
    			 sMyTime.cHoliday = 'Memorial Day';
    			 }
    		    }
    	       }
    	  CASE JUNE:
    	       {
    	       SELECT
    		    {
    		    ACTIVE(sMyTime.nDayOfMonth == 14):
    			 {
    			 sMyTime.cHoliday = "'Flag Day'";
    			 }
    		    ACTIVE(sMyTime.nDayOfMonth == 21):
    			 {
    			 sMyTime.cHoliday = "'Summer Solstice'";
    			 }
    		    ACTIVE(sMyTime.nDayOccurance[SUNDAY] == THIRD && sMyTime.nDayOfWeek == SUNDAY):
    			 {
    			 sMyTime.cHoliday = "'Father',39,'s Day'";
    			 } 
    		    }
    	       }
    	  CASE JULY:
    	       {
    	       if(sMyTime.nDayOfMonth == 4)
    		    {
    		    sMyTime.cHoliday = 'Independence Day';
    		    }
    	       }
    	  CASE AUGUST:
    	       {
    	       if(sMyTime.nDayOccurance[SUNDAY] == FIRST && sMyTime.nDayOfWeek == SUNDAY)
    		    {
    		    sMyTime.cHoliday = "'Friendship Day'";
    		    } 
    	       }
    	  CASE SEPTEMBER:
    	       {
    	       if(sMyTime.nDayOccurance[MONDAY] == FIRST && sMyTime.nDayOfWeek == MONDAY)
    		    {
    		    sMyTime.cHoliday = 'Labor Day';
    		    }
    	       }
    	  CASE OCTOBER:
    	       {
    	       if(sMyTime.nDayOfMonth == 31)
    		    {
    		    sMyTime.cHoliday = 'Halloween';
    		    }
    	       }
    	  CASE NOVEMBER:
    	       {
    	       SELECT
    		    {
    		    ACTIVE(sMyTime.nDayOfMonth == 1):
    			 {
    			 sMyTime.cHoliday = "'All Saint',39,'s Day'";
    			 }
    		    ACTIVE(sMyTime.nDayOfMonth == 11):
    			 {
    			 sMyTime.cHoliday = "'Veteran',39,'s Day'";
    			 }
    		    ACTIVE(sMyTime.nDayOccurance[THURSDAY] == FOURTH && sMyTime.nDayOfWeek == THURSDAY):
    			 {
    			 sMyTime.cHoliday = 'Thanksgiving Day';
    			 }
    		    }
    	       }
    	  CASE DECEMBER:
    	       {
    	       SELECT
    		    {
    		    ACTIVE(sMyTime.nDayOfMonth >= 1 && sMyTime.nDayOfMonth <= 23):
    			 {
    			 sMyTime.cHoliday = "ITOA(25 - sMyTime.nDayOfMonth),' days to Christmas'";
    			 }
    		    (*
    		    ACTIVE(sMyTime.nDayOfMonth == 21):
    			 {
    			 sMyTime.cHoliday = 'Winter Solstice';
    			 }
    		    *)
    		    ACTIVE(sMyTime.nDayOfMonth == 24):
    			 {
    			 sMyTime.cHoliday = 'Christmas Eve';
    			 }
    		    ACTIVE(sMyTime.nDayOfMonth == 25):
    			 {
    			 sMyTime.cHoliday = 'Christmas Day';
    			 }
    		    ACTIVE(sMyTime.nDayOfMonth == 31):
    			 {
    			 sMyTime.cHoliday = "'New Year',39,'s Eve'";
    			 }
    		    }
    	       }
    	  }
         if(length_string(sMyTime.cHoliday))
    	  {
    	  sMyTime.cHoliday = "'[ ',sMyTime.cHoliday,' ]'";
    	  fnTime_DeBug("'fnFindHolidays(): Today is ',sMyTime.cHoliday,' :DEBUG <',ITOA(__LINE__),'>'");
    	  }
         else
    	  {
    	  fnTime_DeBug("'fnFindHolidays(): Today is not a "supported" holiday! :DEBUG <',ITOA(__LINE__),'>'");
    	  }
    	  
         fnFB_Time(UI_UPDATE_ACTIVE,FB_TIME_HOLIDAY);
         
         RETURN;
         }
         
    DEFINE_FUNCTION fnGet_WebDATE_TIME()
    
         {
         sMyTime.cWebCurDateTime = "fnDo_24hrTimeAddition(LDate,TIME,0),' EST'";
         sMyTime.cWebExpDateTime = "fnDo_24hrTimeAddition(LDate,TIME,EXPIRES_IN_SECONDS),' EST'";
        
         RETURN;
         }
         
    DEFINE_FUNCTION fnRun_SunRise_Set(INTEGER iDaytime)
    
         {
         //SWITCH(iDaytime)
    //	  {
    //	  CASE 0:{} //night
    //	  CASE 1:{} //day
    //	  }
         
         fnMain_SunRise_Set(iDaytime);
         }
         
    DEFINE_FUNCTION fnRun_D_O_W_Events(INTEGER iDayOfWeek)   //<<**************  CHANGE SETTING PER JOB **********************************>>>
    
         {
         STACK_VAR INTEGER nCopyDOW;
         
         nCopyDOW = iDayOfWeek;
         //SELECT ACTIVE or SWITCH CASE to do something
         }     
         
    DEFINE_FUNCTION fnRun_D_O_M_Events(INTEGER iDayOfMonth)  //<<**************  CHANGE SETTING PER JOB **********************************>>>
    
         {//uncomment call in fnUpdate_Time()
         STACK_VAR INTEGER nCopyDOM;
         
         nCopyDOM  = iDayOfMonth;
         //SELECT ACTIVE or SWITCH CASE to do something
         }
         
    DEFINE_FUNCTION fnRun_DailyEvents()                      //<<**************  CHANGE SETTING PER JOB **********************************>>>
    
         {
         //fnDailyEmailTest();
         fnGet_Holiday();
         fnGet_AstroClock();
         //SELECT ACTIVE or SWITCH CASE to do something
         fnMain_EveryDay();
         }
         
    DEFINE_FUNCTION fnRun_HourEvents(INTEGER iHour)          //<<**************  CHANGE SETTING PER JOB **********************************>>>
    
         {
         STACK_VAR INTEGER nCopyHour;
         
         nCopyHour  = iHour;
         
         fnMain_EveryHour(nCopyHour);
         //SELECT ACTIVE or SWITCH CASE to do something
         }
    
    DEFINE_FUNCTION fnRun_MinuteEvents(INTEGER iMinute)      //<<**************  CHANGE SETTING PER JOB **********************************>>>
    
         {
         STACK_VAR INTEGER nCopyMinute;
         
         nCopyMinute  = iMinute;
         
         fnMain_EveryMinute(nCopyMinute);
         } 
    
    DEFINE_FUNCTION fnRun_SecondEvents(INTEGER iSecond)      //<<**************  CHANGE SETTING PER JOB **********************************>>>
    
         {
         STACK_VAR INTEGER nCopySecond;
         
         nCopySecond = iSecond;
         
         fnMain_EverySecond(nCopySecond);
         }
         
    DEFINE_FUNCTION fnRun_StartUpCode() 
    
         {
         LOCAL_VAR CLKMGR_TIMEOFFSET_STRUCT sMyCLKMGR_TIMEOFFSET;
         
         fnTime_DeBug("'fnRunStartUpCode(): Run Start Up! :DEBUG <',ITOA(__LINE__),'>'");
         nTimeWait_Force = 1;
         
         sMyDST.nObserved = DST_OBSERVED;
         
         if(sMyDST.nObserved)
    	  {
    	  sMyDST.nOffset	= DST_OFFSET;
    	  sMyDST.nBEG_Month	= DST_BEGIN_MONTH;
    	  sMyDST.nEND_Month     = DST_END_MONTH;
    	  sMyDST.nBEG_Day       = DST_BEGIN_DAY;
    	  sMyDST.nEND_Day 	= DST_END_DAY;
    	  sMyDST.nBEG_DAY_Occurance = DST_BEGINDAY_OCCURANCE;
    	  sMyDST.nEND_DAY_Occurance = DST_ENDDAY_OCCURANCE;
    	  }     
         
         WAIT 300//3000
    	  {
    	  fnTime_DeBug("'fnRunStartUpCode(): Run Start Up Wait items! :DEBUG <',ITOA(__LINE__),'>'");
    	  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);//moved to DST function
    	  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);
    	  
    	  nTimeWait_Force = 2;
    	  fnUpdate_Time();
    	  }
         if(!TIMELINE_ACTIVE(TL_TIME))
    	  {
    	  TIMELINE_CREATE(TL_TIME,nTL_TIME_RT,1,timeline_absolute,timeline_repeat);
    	  }
         }
         
    DEFINE_FUNCTION fnUpdate_Time()
         
         {
         if(sMyTime.nSecond != TYPE_CAST(TIME_TO_SECOND(TIME)) || nTimeWait_Force)
    	  {
    	  sMyTime.nSecond = TYPE_CAST(TIME_TO_SECOND(TIME));
    	  sMyTime.c24Time = TIME;
    	  if(sMyTime.nMinute != TYPE_CAST(TIME_TO_MINUTE(TIME)) || nTimeWait_Force)
    	       {
    	       sMyTime.nMinute = TYPE_CAST(TIME_TO_MINUTE(TIME));
    	       //only 1 minute resolution for sunrise/set, could check every second but why, not that critical.....
    	       if(sMyTime.nTime_Seconds >= sMyTime.nSunriseTime && sMyTime.nTime_Seconds < sMyTime.nSunsetTime)
    		    {
    		    if(!sMyTime.nDaytime)
    			 {
    			 sMyTime.nDaytime = 1;
    			 fnRun_SunRise_Set(sMyTime.nDaytime);
    			 }
    		    }
    	       else 
    		    {
    		    if(sMyTime.nDaytime)
    			 {
    			 sMyTime.nDaytime = 0;
    			 fnRun_SunRise_Set(sMyTime.nDaytime);
    			 }
    		    }			 
    	       if(sMyTime.n24Hour != TYPE_CAST(TIME_TO_HOUR(TIME)) || nTimeWait_Force)
    		    {
    		    sMyTime.n24Hour = TYPE_CAST(TIME_TO_HOUR(TIME));
    		    if(sMyTime.n24Hour >= 12)
    			 {
    			 sMyTime.cAMPM = 'PM';
    			 sMyTime.nTimePM_flag = 1;
    			 if(sMyTime.n24Hour > 12)
    			      {
    			      sMyTime.n12Hour = sMyTime.n24Hour - 12;
    			      }
    			 else
    			      {
    			      sMyTime.n12Hour = sMyTime.n24Hour;
    			      }
    			 }
    		    else
    			 {
    			 sMyTime.cAMPM = 'AM';
    			 sMyTime.nTimePM_flag = 0;
    			 sMyTime.n12Hour = sMyTime.n24Hour;
    			 }
    		    sMyTime.c12Time = "itoa(sMyTime.n12Hour),':',RIGHT_STRING("'0',itoa(sMyTime.nMinute)",2),':',RIGHT_STRING("'0',itoa(sMyTime.nSecond)",2)";
    		    if(sMyTime.nDayOfMonth != TYPE_CAST(DATE_TO_DAY(LDATE)) || nTimeWait_Force)
    			 {
    			 sMyTime.nDayOfMonth = TYPE_CAST(DATE_TO_DAY(LDATE));
    			 sMyTime.nDayOfWeek = TYPE_CAST(DAY_OF_WEEK(LDATE));
    			 if(sMyTime.nMonth != TYPE_CAST(DATE_TO_MONTH(LDATE)))//no force here.  would erase stored values.
    			      {
    			      sMyTime.nMonth = TYPE_CAST(DATE_TO_MONTH(LDATE));
    			      if(sMyTime.nYear != TYPE_CAST(DATE_TO_YEAR(LDATE)))
    				   {
    				   sMyTime.nYear = TYPE_CAST(DATE_TO_YEAR(LDATE));
    				   }
    			      }
    			 if(sMyTime.cDay != Day || nTimeWait_Force)
    			      {
    			      sMyTime.cDay = Day;
    			      if (sMyTime.cDate != Date)
    				   {
    				   sMyTime.cDate = Date;
    				   }
    			      }
    			 fnGet_DayOccurrences();
    			 fnRun_D_O_W_Events(sMyTime.nDayOfWeek);
    			 fnRun_D_O_M_Events(sMyTime.nDayOfMonth);
    			 fnRun_DailyEvents();
    			 }
    		    fnRun_HourEvents(sMyTime.n24Hour);
    		    }
    	       else
    		    {
    		    sMyTime.c12Time = "itoa(sMyTime.n12Hour),':',RIGHT_STRING("'0',itoa(sMyTime.nMinute)",2),':',RIGHT_STRING("'0',itoa(sMyTime.nSecond)",2)";
    		    }
    	       sMyTime.nTime_Minutes = ((sMyTime.n24Hour * 60) + sMyTime.nMinute);
    	       fnRun_MinuteEvents(sMyTime.nMinute);
    	       }
    	  else
    	       {
    	       sMyTime.c12Time = "itoa(sMyTime.n12Hour),':',RIGHT_STRING("'0',itoa(sMyTime.nMinute)",2),':',RIGHT_STRING("'0',itoa(sMyTime.nSecond)",2)";
    	       }
    	  sMyTime.nTime_Seconds = ((((sMyTime.n24Hour * 60) + sMyTime.nMinute) * 60) + sMyTime.nSecond);
    	  fnRun_SecondEvents(sMyTime.nSecond);
    	  fnFB_Time(UI_UPDATE_ACTIVE,FB_TIME_TIME); //IF ANYTHING NEEDS TIME UPDATES
    	  }
         nTimeWait_Force  = 0;
         }
              
    DEFINE_START    //RUN START UP CODE
    
         
    fnRun_StartUpCode();
    
    DEFINE_EVENT    //TIMELINE_EVENT [TL_TIME]
    
    TIMELINE_EVENT [TL_TIME]//EVERY 250ms
        
         {
         fnUpdate_Time();
         fnMain_250ms_Clock();//put any other timing events in the main in this function
         }
         
    DEFINE_PROGRAM  //CALL fnUpdate_Time() if you don't have a timeline elsewhere to call it every second
    (*
    WAIT 10
         {
         fnUpdate_Time();
         }
    *)
    if(!TIMELINE_ACTIVE(TL_TIME))
         {
         TIMELINE_CREATE(TL_TIME,nTL_TIME_RT,1,timeline_absolute,timeline_repeat);
         }
    
  • viningvining X Member Posts: 4,341
    John_Glove wrote: »
    hi all

    thanks for the replies.

    first, sorry i mean midnight correct :-)
    my channel_event works on midnight every night. i do this with (COMPARE_STRING(TIME,'00:05:0?'))
    my problem is in the ON event of the channel_event the cmd:

    nDay = DAY_OF_WEEK (DATE)

    doesn't be updatet. all other cmd in this event works.

    example:

    CHANNEL_EVENT[vdv__EVENT,003]
    {
    ON:
    {
    nDAY = DAY_OF_WEEK (DATE)

    }
    }

    Try (LDATE) instead of (DATE)
  • John_GloveJohn_Glove Junior Member Posts: 95
    hi
    thanks for the code!

    i have on all my system's at home this compare_string for minute/hour/day/month/year. this works for a long time without no problem, so i don't want to change them.
    the cmd: nDAY = DAY_OF_WEEK (DATE) works on other event's like startup. and gives me the correct day back.
    only in the specified channel_event it doesn't works. that's what i didn't understand
    the cmd works and the channel_event is triggered, but together.....

    that's my question ;-)
  • GregGGregG Just some guy... Posts: 249
    For fun and testing purposes I ran this code on my master:
    Button_Event[dvTP,1]
    {
    	Push: Pulse[vdvDevice,3]
    }
    
    Channel_Event[vdvDevice,3]
    {
    	On:
    	{
    		nDay = 999 // So we can tell if nothing happened
    		
    		// Using DATE
    		nDay = DAY_OF_WEEK (DATE) 
    		Send_String 0,"'nDAY=',Itoa(nDay),' DAY_OF_WEEK(DATE)=',Itoa(DAY_OF_WEEK(DATE))"
    		
    		// Using LDATE
    		nDay = DAY_OF_WEEK (LDATE) 
    		Send_String 0,"'nDAY=',Itoa(nDay),' DAY_OF_WEEK(LDATE)=',Itoa(DAY_OF_WEEK(LDATE))"
    	}
    }
    

    And this was the output when I did the button push:
    (0000118402) nDAY=5 DAY_OF_WEEK(DATE)=5
    (0000118403) nDAY=5 DAY_OF_WEEK(LDATE)=5
    

    So, doing those functions in a channel event is not inherently broken on the AMX side.
  • DHawthorneDHawthorne Junior Member Posts: 4,584
    Instead of linking it to a channel event (which seems to be the sticking point), put this in a timeline, or in mainline:
    IF (sDate <> DATE)
    {   // stuff to happen when the day changes
         nDAY = DAY_OF_WEEK (DATE) ;
         sDate = DATE ;
    }
    

    ... where sDate is a globally defined CHAR array. I make it a nonvolatile variable so a reboot won't force the event.
  • John_GloveJohn_Glove Junior Member Posts: 95
    so i have the solution working (for me):

    with the nDay variable i make some channel_event's (one channel for every_day)

    thanks for all the help!

    john
Sign In or Register to comment.