Hi,
I need some feedback/advise on how 'easy' or difficult is it to write this program or maybe anyone know of good example date program that I can start with.
I need a datetime program that I can use that will accept date arguments in some datetime format and perform arithmetic on them. Example of what I am wanting to do as below, for example if the program is named mydatetime, sample run can be as follows:
mydatetime 25-OCT-2014 20-OCT-2014
- should print out the difference between the two in hours and minutes, sec
mydatetime 25-OCT-2014 -2
- should printout the date and time 2 days back
mydatetime 25-OCT-2014 2
- should printout the datet and ime 2 days in the future
mydatetime
- should print out the current date and time.
For simplicity, I did not include the time above but I would want to include the timestamp as well and then perform the arithmetic in the date and time format as well.
Currently, I am using a shell script that connect to a database and do the date calculation there . I did not have to install the database, there just happen to have an Oracle/DB2/Sybase database on most of the script that I needed to do date calculation on. I know need to do the same on a server where there is no database on.
I can't use a Perl one since our SA don't want to install the additional modules that I need to use for some examples that I found so I am stucked with maybe writing my own C program which I know nothing about.
In 'simple' terms, I need to have the program to do as below:
- 01 - Check for command line argument, if nothing print current date
- 02 - Check for command line argument that they are in the date format that the program expects and then do perform the date arithmetic giving the result in date or in number of days/hours-min-sec
Any advice much appreciated. Thanks in advance.