Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Date calculations with stock and Gnu versions of 'date'' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Date calculations with stock and Gnu versions of 'date'
Authored by: Austin-Soft.com on Jul 25, '08 08:22:41AM
Actually, to see the last day of February (not the first day of March), the command would be:
date -v3m -v1d -v-1d


[ Reply to This | # ]
Date calculations with stock and Gnu versions of 'date'
Authored by: S Barman on Jul 25, '08 08:56:23PM
To use the above, if you want to create a shell variable to test whether it is a leap year, you can use:
leap=$((`date -v3m -v1d -v-1d +'%d'`-28))
You can then check the variable $leap. If it is one (1), then it is a leap year! Enjoy. Scott

[ Reply to This | # ]
Date calculations with stock and Gnu versions of 'date'
Authored by: rahulbenegal on Jul 26, '08 09:37:51PM

Yes, you are correct, at the time of writing I had overwritten my stock date program.

@soujuorner, perhaps you have another version of date in your path - the gnu version.

Try the gnu option. Or do "which date". If its in /opt/local/bin, it would be the gnu version. If it's /usr/bin/date, that should be the stock version which supports the -v option.

Do "date --help" to see whether it supports "--date" or "-v".



[ Reply to This | # ]