Don’t. This is a lot trickier than it sounds. Leave it to code that’s already been in use and debugged for years, and just use a tool that can handle your needs. Odds are high that one of the other recipes in this chapter has covered what you need, probably using GNU date. If not, there is almost certainly another tool out there that can do the job. For example, there are a number of excellent Perl modules that deal with dates and times.
Really, we aren’t kidding. This is a real nightmare to get right. Save yourself a lot of agony and just use a tool.
3.133.116.137