Das Open-Control-Projekt - Die Alternative zur C-Control-I


Das Forum zur C-Control-1
Welche C-Control-Varianten existieren?
Übersicht - Suchen - Neueste 50 Beiträge - Neuer Beitrag - Login - Registrieren
INFO - FAQ - CC2-Forum - CCPro-Forum 

 Re: Funkuhr Sommerzeit/Winterzeit Kategorie: Programmierung Basic (von Jürgen Christoph - 7.07.2004 16:51)
 Als Antwort auf Re: Funkuhr Sommerzeit/Winterzeit von Jürgen Christoph - 7.07.2004 13:52
Anbei der genannte Basic Code zur Ermittlung der Sommer/Winterzeit
anhand des Datums:


'----------------------------------------------------------------------------
' Variables words / bytes / bits (assigned manually, adjust as needed)
'----------------------------------------------------------------------------

DEFINE  IsSummerTime  bit [180] ' Global Summertime bit
DEFINE  TempBIT       bit [181] ' Temporary general purpose bit
DEFINE  DWH           byte [19] ' Temporary general purpose byte variable

'----------------------------------------------------------------------------
' Function:    GetSummerTimeBit
' Description: Calculate the IsSummerTime bit
' Parameter:   -
' Result:      IsSummerTime
' Caution:     The time variables MINUTE/HOUR/DAY/MONTH/DOW must contain
'              valid data, that means, system time must be set.
'----------------------------------------------------------------------------
#GetSummerTimeBit
  ' Make sure the variables HOUR/DAY/DOW/MONTH do not change during this code
  ' execution by storing the least significant bit of the time and check
  ' again at function exit.
  ' You may omit this, if the function is called at appropriate times only.
  TempBIT = -(MINUTE AND 1)   ' Note: bits are 0 or -1 on this machine

  'Initialize the result bit to wintertime as default
  IsSummerTime = OFF
 
  'Now check MONTH ranges
  IF ((MONTH > 3) AND (MONTH < 10)) THEN IsSummerTime = ON
 
  'If any month except march or october, we're done.
  IF (MONTH <> 3) AND (MONTH <> 10) THEN GOTO localGetSummerTimeBitExit

  'Actually it is march or october.
  'If march assume SummerTime, if october assume wintertime
  'So assume for now, last sunday of the month has been reached.
  IF (MONTH = 3) THEN IsSummerTime = ON ' else the MONTH is 10
 
  'Get the day of the last sunday of that month
  'Algorithm does work with "31 day" months only, however
  'march and october have 31 days.
  'Note about DOW bug: Here DOW may by 0 or 7 in case of
  'Sunday, that doesn't matter due to the MOD operator.
  DWH = ((DAY + 10 - DOW) MOD 7) + 25
 
  'If that sunday has not been reached yet, then invert the
  'assumption above, that means invert the result bit.
  IF (DAY <  DWH) THEN IsSummerTime = NOT IsSummerTime
 
  'It is not the last sunday in march/october? Then we're done.
  IF (DAY <> DWH) THEN GOTO localGetSummerTimeBitExit
 
  'It is the Sunday in question. Now check the time.
  'Algorithm is not 100% perfect for october between 02:00
  'and 03:00, because that time period exits twice, but
  'that should not be a real problem in most applications.
  IF (HOUR < 2) THEN IsSummerTime = NOT IsSummerTime

#localGetSummerTimeBitExit
  'Finally check if during the calculation done, the time
  'has changed, which might affect variables HOUR/DAY/...
  'This can be done by checking a single bit in the MINUTE
  'variable. In the worst case, the MINUTE just changed,
  'but that happens not again when the code is executed
  'once more.
  IF (-(MINUTE AND 1) <> TempBIT) THEN GOTO GetSummerTimeBit
 
RETURN

 Antwort schreiben

Bisherige Antworten:

Re: Funkuhr Sommerzeit/Winterzeit (von Jan - 7.07.2004 20:58)
    Re: Funkuhr Sommerzeit/Winterzeit (von Peter Grzeschik - 3.03.2006 13:44)
        Re: Funkuhr Sommerzeit/Winterzeit (von Dietmar - 4.03.2006 19:18)
            Re: Funkuhr Sommerzeit/Winterzeit (von Peter Grzeschik - 4.03.2006 20:11)
        Re: Funkuhr Sommerzeit/Winterzeit (von Achim - 4.03.2006 14:56)
            Re: Funkuhr Sommerzeit/Winterzeit (von Peter Grzeschik - 4.03.2006 17:48)
                Re: Funkuhr Sommerzeit/Winterzeit (von Achim - 4.03.2006 23:46)
                    Re: Funkuhr Sommerzeit/Winterzeit (von ManfredW - 5.03.2006 1:46)
            Re: Funkuhr Sommerzeit/Winterzeit (von ManfredW - 4.03.2006 15:46)
                Re: Funkuhr Sommerzeit/Winterzeit (von Achim - 4.03.2006 17:48)
        Re: Funkuhr Sommerzeit/Winterzeit (von Hecktor - 4.03.2006 9:09)
            Re: Funkuhr Sommerzeit/Winterzeit (von Peter Grzeschik - 4.03.2006 16:25)
    Re: Funkuhr Sommerzeit/Winterzeit (von Achim - 8.07.2004 10:31)
        Re: Funkuhr Sommerzeit/Winterzeit (von Helmut - 24.09.2005 18:12)
Re: Funkuhr Sommerzeit/Winterzeit (von Jan - 7.07.2004 17:10)
Re: Funkuhr Sommerzeit/Winterzeit (von Achim - 7.07.2004 17:03)
    Re: Funkuhr Sommerzeit/Winterzeit (von Jürgen Christoph - 7.07.2004 20:53)
        Re: Funkuhr Sommerzeit/Winterzeit (von Achim - 8.07.2004 10:23)