Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: can zsh / strftime do "date math"?
- X-seq: zsh-users 16494
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: can zsh / strftime do "date math"?
- Date: Mon, 17 Oct 2011 00:15:40 -0700
- In-reply-to: <CADjGqHvM1EqQxLpJTugMr73FLbPPtHF+AVdz=qKZuhtr4shYLA@mail.gmail.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CADjGqHvM1EqQxLpJTugMr73FLbPPtHF+AVdz=qKZuhtr4shYLA@mail.gmail.com>
On Oct 17, 1:36am, TJ Luoma wrote:
} Subject: can zsh / strftime do "date math"?
}
} I use the 'gdate' program the from the GNU coreutils to do "date math"
} (I don't know if that's the right term or not).
}
} For example, if I wanted to know the time would be in 17 hours, 14
} minutes, and 6 seconds, I would use
}
} gdate --date "+ 17 hours 14 minutes 06 seconds"
The closest would be:
zmodload zsh/datetime
strftime '%Y%m%d %H:%M:%S' $[EPOCHSECONDS + (17 * 60 + 14) * 60 + 6]
You can also parse datetimes with "strftime -r" but you must include
the year month and day and which must be more recent than 1969/12/12,
so you can't use it to parse "+ 17 hours 14 minutes 06 seconds".
Messages sorted by:
Reverse Date,
Date,
Thread,
Author