Date manipulation functions in ksh/bsh

Date manipulation functions in ksh/bsh

Post by Mehul Zaver » Mon, 22 May 2000 04:00:00



Dear friends,

Does anybody have readymade routines (shell function/script) for date
manipulation.
Or are there any aix command (what expr does for numbers), which can do the
date subtraction/addition etc ?

Any help would be greatly appreciated.

Regards,
Mehul.

 
 
 

Date manipulation functions in ksh/bsh

Post by Matthew Land » Tue, 23 May 2000 04:00:00



> Dear friends,

> Does anybody have readymade routines (shell function/script) for date
> manipulation.
> Or are there any aix command (what expr does for numbers), which can do the
> date subtraction/addition etc ?

> Any help would be greatly appreciated.

> Regards,
> Mehul.

gnudate would probably be the easiest solution.

There are some scripts out there, but many have problems with leapyear,
daylight savings, and other special time oddities.  Gnudate not only
allows date adding/subtracting, but like date, it allows you to output
in the format you want.  Other scripts are hard coded to one format,
so if you want it in another format, you have to write more scripts.

 - Matt

 
 
 

Date manipulation functions in ksh/bsh

Post by Tony R. Benne » Wed, 24 May 2000 04:00:00




 >>
 >> Dear friends,
 >>
 >> Does anybody have readymade routines (shell function/script) for date
 >> manipulation.
 >> Or are there any aix command (what expr does for numbers), which can do the
 >> date subtraction/addition etc ?
 >>
 >> Any help would be greatly appreciated.
 >>
 >> Regards,
 >> Mehul.
 >
 >gnudate would probably be the easiest solution.
 >
 >There are some scripts out there, but many have problems with leapyear,
 >daylight savings, and other special time oddities.  Gnudate not only
 >allows date adding/subtracting, but like date, it allows you to output
 >in the format you want.  Other scripts are hard coded to one format,
 >so if you want it in another format, you have to write more scripts.
 >
 > - Matt

Another solution would be to use PERL...
...and us its time() and localtime() functions and you can pick
how to format the output.

For example, to find the date two days ago:

        #!/usr/local/bin/perl
        #
        $time_now = time();
        $prior_time = $time_now - (60 * 60 * 24 * 2);
        ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)
                  = localtime($prior_time);
        #
        # format: YYYYMMDD
        #
        printf( "%4.4d%2.2d%2.2d\n",
                $year+1900, $mon+1, $mday);

--


 
 
 

Date manipulation functions in ksh/bsh

Post by Mehul Zaver » Thu, 25 May 2000 04:00:00


Dear Matthew,
Thanks for your response.

However, I couldn't get "gnudate" any where on www.gnu.org. ( I searched all
versions of shell utils out there)
Appreciate if you can give me the full web address  whereby I can download
gnudate?

Thanks in advance
Warm regards,
Mehul.



> > Dear friends,

> > Does anybody have readymade routines (shell function/script) for date
> > manipulation.
> > Or are there any aix command (what expr does for numbers), which can do
the
> > date subtraction/addition etc ?

> > Any help would be greatly appreciated.

> > Regards,
> > Mehul.

> gnudate would probably be the easiest solution.

> There are some scripts out there, but many have problems with leapyear,
> daylight savings, and other special time oddities.  Gnudate not only
> allows date adding/subtracting, but like date, it allows you to output
> in the format you want.  Other scripts are hard coded to one format,
> so if you want it in another format, you have to write more scripts.

>  - Matt

 
 
 

Date manipulation functions in ksh/bsh

Post by Matthew Land » Thu, 25 May 2000 04:00:00



> Dear Matthew,
> Thanks for your response.

> However, I couldn't get "gnudate" any where on www.gnu.org. ( I searched all
> versions of shell utils out there)
> Appreciate if you can give me the full web address  whereby I can download
> gnudate?

> Thanks in advance
> Warm regards,
> Mehul.

Yes, GNU date is not a package by itself.  It is part of the sh-utils
package.  I was unable to find a binary version for AIX at the bull site
but the tar.gz can be found at:

ftp://prep.ai.mit.edu/pub/gnu/sh-utils/

Info at:

http://www.delorie.com/gnu/docs/sh-utils/sh-utils_57.html

 - Matt

 
 
 

1. Anybody w/date conv/calc Bsh/ksh script?

I desperately need a script that can convert back and forth from julian
to mm/dd/yy..
If someone can get me started with a /bin/sh or /bin/ksh script...
I'd be most appreciated..
(Hey, I'm not extremely picky, a c source file would be great--
just can't use perl or an GNU products!)

2. Logging of printer usage

3. date manipulation under csh/ksh under solaris

4. What is a 'door' file?

5. date manipulation in ksh

6. Need info on various aspects of unix processes

7. ksh date manipulation

8. fortran and mesa in linux

9. Functions for Date Arithmetic in Ksh.

10. bsh & ksh running setuid

11. bsh vs. ksh (cd command)

12. ksh/bsh/sh script for splitting out $QUERY_STRING

13. bsh vs. ksh (cd command)