[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Command-line-interface (CLI) calculator to work out the difference between 2 dates



On 24 Ago, 17:10, "j t" <mark...@gmail.com> wrote:
> [snip]
>
> (I'm happy to use any date format for input - I've only used ISO8601
> as an example)

Maybe something like that:

#!/usr/bin/python

from time import mktime, strptime
from sys import argv

class DummyDate:
    def __init__(self, strdate, format):
        self.ticks = mktime(strptime(strdate, format));

    def __sub__(self, obj):
        return int(self.ticks - obj.ticks) / 86400;

(prg, a, b, fmt) = argv
print DummyDate(a, fmt) - DummyDate(b, fmt)
## end

Or using a sh script with date(1)

>
> J :-)

s.


Reply to: