Daylight Saving Time

Daylight Saving Time

Post by K Stah » Fri, 24 Mar 2000 04:00:00



Does anyone have a shell script which can be used to determine the date on
which the shift between standard time and daylight time will occur? What I
want to be able to do is run the script and have it return a default
machine-readable date (i.e. YYYYMMDD) of the date that the shift will occur
with an optional switch which will return the number of days until the next
shift occurs. Thus, if it is run on the Sunday that occurs just one week
prior to the shift the return value will be 7. If it is run on the day that
the shift occurs it would return approximately 180 days.
 
 
 

Daylight Saving Time

Post by Ken Pizzi » Sat, 25 Mar 2000 04:00:00



>Does anyone have a shell script which can be used to determine the date on
>which the shift between standard time and daylight time will occur?

What assumptions can we make about the system?  Does the sytem
use the Olsen TZ database?  Can we use the "mktime" (or GNU
date) utility?

Quote:> What I
>want to be able to do is run the script and have it return a default
>machine-readable date (i.e. YYYYMMDD) of the date that the shift will occur
>with an optional switch which will return the number of days until the next
>shift occurs. Thus, if it is run on the Sunday that occurs just one week
>prior to the shift the return value will be 7. If it is run on the day that
>the shift occurs it would return approximately 180 days.

Does this need to handle only current-day US rules, or does it
need to handle all such transitions which occured around the
globe since the beginning of standardized time zones?

                --Ken Pizzini

 
 
 

Daylight Saving Time

Post by K Stah » Sat, 25 Mar 2000 04:00:00




> >Does anyone have a shell script which can be used to determine the date on
> >which the shift between standard time and daylight time will occur?

> What assumptions can we make about the system?  Does the sytem
> use the Olsen TZ database?  Can we use the "mktime" (or GNU
> date) utility?

Assume vanilla SCO Unixware 2.1.2 and Solaris 2.6. You can assume mktime as
a Man 3 function but not Man 1.

Quote:> > What I
> >want to be able to do is run the script and have it return a default
> >machine-readable date (i.e. YYYYMMDD) of the date that the shift will occur
> >with an optional switch which will return the number of days until the next
> >shift occurs. Thus, if it is run on the Sunday that occurs just one week
> >prior to the shift the return value will be 7. If it is run on the day that
> >the shift occurs it would return approximately 180 days.

> Does this need to handle only current-day US rules, or does it
> need to handle all such transitions which occured around the
> globe since the beginning of standardized time zones?

>                 --Ken Pizzini

It needs to work only US rules and can disregard any odd places like those
that do not use daylight time.

Basically I'm looking for something that is quick and dirty for EST/EDT.

 
 
 

Daylight Saving Time

Post by Ken Pizzi » Sun, 26 Mar 2000 04:00:00



>> >Does anyone have a shell script which can be used to determine the date on
>> >which the shift between standard time and daylight time will occur?
>Assume vanilla SCO Unixware 2.1.2 and Solaris 2.6. You can assume mktime as
>a Man 3 function but not Man 1.

Well, the PD mktime(1) command is basically a wrapper around
mktime(3), and mktime(3) is kinda useless by itself for a shell
script...

Quote:>> > What I
>> >want to be able to do is run the script and have it return a default
>> >machine-readable date (i.e. YYYYMMDD) of the date that the shift will occur
>It needs to work only US rules and can disregard any odd places like those
>that do not use daylight time.

>Basically I'm looking for something that is quick and dirty for EST/EDT.

Currently for US timezones which observe Daylight Saving time
the rule is:
  Spring forward the first Sunday in April at 02:00 local Standard time;
  Fall back on the last Sunday in October at 02:00 local Daylight time.

Now a Q&D solution won't worry about any changes to this rule in
the past or in the future.  A solution which needs to work on
any system (without requiring any non-standard tools) would be
well advised to use "cal" to figure out when the next shift will
occur:
  #! /bin/sh
  case $# in [012]) set `date +'%Y %m %d'` ;; esac
  year=$1 m=$2 d=$3
  yp1=`expr $year + 1`
  fsia=`cal  4 $year | sed '/^ [0-9]/!d; s/ \(.\).*/0\1/; q'`
  lsio=`cal 10 $year | sed '/^[0-9][0-9]/h; $!d; g; s/ .*//'`
  nyfsia=`cal  4 $yp1 | sed '/^ [0-9]/!d; s/ \(.\).*/0\1/; q'`
  case $m in
    0[123]) transiton="$year-04-$fsia" ;;
    04)     if [ "$d" -lt "$fsia" ]; then
              transiton="$year-04-$fsia"
            else
              transiton="$year-10-$lsio"
            fi ;;
    0[5-9]) echo "$year-10-$lsio" ;;
    10)     if [ "$d" -lt "$lsio" ]; then
              transiton="$year-10-$lsio"
            else
              transiton= "$yp1-04-$nyfsia"
            fi ;;
    *)      transiton= "$yp1-04-$nyfsia" ;;
  esac
  echo "next DST transition occurs at 02:00 on $transition"

To calculate days between dates the easiest thing is to convert
both dates to a Julian date (or MJD, if you prefer) and then
simply subtract.  Shell code to make the conversion has been
posted to this newsgroup in the past.  ('Course this all would
be much easier if you would just install the mktime utility.
Surely maintaining that PD program is less work than maintaining
Q&D shell kludges?)

                --Ken Pizzini

 
 
 

1. Problems with daylight saving time

Hi there,

we syschronise the linux system to a radio controled clock via the
command "nwfstime". This command asks a novell server for the time (the
server time is radio controled). Since the time changed to daylight
saving time the command "nwfstime" does not return the daylight saving
time, it returns the "normal time".
Does anybody know whether the is a problem of "nwfstime" or of our
TIMEZONE setting and what's the right way to solve the problem?

P.S.: The time on the novell server is daylight saving time, we checked
this on another way.

Bye,
Erik

Erik Vellmete
MLP Dignos Software GmbH
Im Breitspiel 11
D-69126 Heidelberg
Tel.: 06221/348-765
Fax.: 06221/348-711

2. Actual behavior of realloc()

3. Help with Daylight saving time...

4. Bad Magic Number ? - Recovery ?

5. Changing to Daylight Saving TIme

6. ifconfig SIOCSIFFLAGS error, Intel EtherExpress card, 1.3.4 kernel

7. Daylight saving time methods?

8. Turning off shadow passwords on RH6.1 ?

9. ctime() problem with daylight saving time?

10. New daylight saving time code for SunOS 4.x?

11. daylight saving time

12. Daylight Saving Time

13. How to test daylight saving time?