Veritas-bu

[Veritas-bu] Date conversion functions

2000-06-27 14:06:19
Subject: [Veritas-bu] Date conversion functions
From: Pat Whelan pwhelan AT veritas DOT com
Date: Tue, 27 Jun 2000 11:06:19 -0700
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_000_01BFE062.64EDA158
Content-Type: text/plain;
        charset="iso-8859-1"

See if this helps.

 <<ctime.sh>> 
Patrick Whelan 
Consulting 
[NBU (with extensions) and Storage Migrator] 
[VxFS and Volume Manager]
pwhelan AT veritas DOT com

Of course this is just my opinion, I could be wrong. - Dennis Miller
Friends help friends move, good friends help move bodies - Unknown.



                -----Original Message-----
                From:   Laszlo, Kathy [mailto:KLaszlo AT petro-canada DOT ca]
                Sent:   Tuesday, June 27, 2000 1:07 PM
                To:     'veritas-bu AT mailman.eng.auburn DOT edu'
                Subject:        [Veritas-bu] Date conversion functions


                I know about the undocumented feature of bpdbm that will
convert an "epoch
                date" number to a readable date.
                For example:

                /usr/openv/netbackup/bin/bpdbm -ctime 0962121220
                962121220 = Tue Jun 27 09:53:40 2000

                Is there a function that will convert a readable date to an
"epoch date"?

                Thanks in advance.


                Kathy Laszlo
                Petro Canada Ltd.
                Calgary, AB, Canada
                _______________________________________________
                Veritas-bu maillist  -  Veritas-bu AT mailman.eng.auburn DOT edu
                http://mailman.eng.auburn.edu/mailman/listinfo/veritas-bu

------_=_NextPart_000_01BFE062.64EDA158
Content-Type: application/octet-stream;
        name="ctime.sh"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
        filename="ctime.sh"

#------------------------ Cut Here ---------------------=0A=
#!/bin/ksh=0A=
#=0A=
# This shell script calculates the "ctime" from the=0A=
# current time. There are no parameters. The output=0A=
# is a number that can, if wanted for testing, be fed=0A=
# to bpdbm -ctime to return the current time in string=0A=
# format. This script can be useful in calculating a =0A=
# "ctime" for comparison purposes.=0A=
#=0A=
# Setup and Initialize some variables=0A=
integer ctime=3D0=0A=
integer currentmo=0A=
integer daoffset=3D0=0A=
integer mooffset=3D1=0A=
integer yroffset=3D2=0A=
integer hroffset=3D3=0A=
integer minoffset=3D4=0A=
integer secoffset=3D5=0A=
integer prevyear=0A=
integer secinmin=3D60=0A=
integer secinhr=3Dsecinmin*60=0A=
integer secinday=3Dsecinhr*24=0A=
integer secin28days=3Dsecinday*28=0A=
integer secin30days=3Dsecinday*30=0A=
integer secin31days=3Dsecinday*31=0A=
integer secin365days=3Dsecinday*365=0A=
integer leap=0A=
integer tyear=0A=
set -A secinmonths 0 $secin31days $secin28days $secin31days =
$secin30days $secin31days $secin30days $secin31days $secin31days =
$secin30days $secin31days  $secin30days =0A=
# The -u option is required. Althought this will return the time in =
GMT=0A=
# when run through bpdbm -ctime it will appear as the correct local =
time=0A=
set -A ty `date -u +"%d %m %Y %H %M %S"`=0A=
prevyear=3D${ty[$yroffset]}=0A=
# Calculate the number of years since 1970=0A=
prevyear=3Dprevyear-1970=0A=
# Calculate the current month [January=3D0]=0A=
currentmo=3Dty[$mooffset]-1=0A=
# The next two lines determine if it is a leap year=0A=
tyear=3Dty[$yroffset]/4=0A=
leap=3Dtyear*4=0A=
# Is this a leap year?=0A=
if [ leap -eq ty[$yroffset] ]=0A=
then=0A=
#       Is the currentmonth after Feburary?=0A=
        if [ currentmo -gt 1 ]=0A=
        then=0A=
#               Initialize ctime to one day=0A=
                ctime=3D$secinday=0A=
        fi=0A=
fi=0A=
# Add the number of seconds=0A=
ctime=3Dctime+ty[$secoffset]=0A=
# Add the number of minutes in seconds=0A=
ctime=3Dctime+ty[$minoffset]*secinmin=0A=
# Add the number of hours in seconds=0A=
ctime=3Dctime+ty[$hroffset]*secinhr=0A=
# Add the number of days this month in seconds=0A=
ctime=3Dctime+ty[$daoffset]*secinday=0A=
# Add the previous months in seconds=0A=
while [ currentmo -ge 0 ]=0A=
do=0A=
        ctime=3Dctime+secinmonths[currentmo]=0A=
        currentmo=3Dcurrentmo-1=0A=
done=0A=
# Add the number of seconds for the previous years=0A=
ctime=3Dctime+(prevyear*secin365days)=0A=
# Since the first leap year after 1970 was 1972=0A=
# subtract 2 from the prevyear calculation=0A=
tyear=3Dprevyear-2=0A=
# Divide the total number of years by 4 to determine the=0A=
# the number of leap years=0A=
tyear=3Dtyear/4=0A=
if [ leap -eq ty[$yroffset] ]=0A=
then=0A=
tyear=3Dtyear-1=0A=
fi=0A=
# Now add the number os seconds in a day for each leap year=0A=
ctime=3Dctime+(tyear*secinday)=0A=
# Return the current time in ctime format. This can be used=0A=
# to compare with the ctimes generated by NetBackup.=0A=
echo $ctime=0A=

------_=_NextPart_000_01BFE062.64EDA158--



<Prev in Thread] Current Thread [Next in Thread>