Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Converting time with EPOCHSECONDS and zmodload zsh/datetime
- X-seq: zsh-users 16275
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: Converting time with EPOCHSECONDS and zmodload zsh/datetime
- Date: Mon, 22 Aug 2011 07:48:41 -0700
- In-reply-to: <CADjGqHukXSkVVkbt9F=MmGgu551gybG2bnR=xR5UoQXjWuKYTA@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: <CADjGqHukXSkVVkbt9F=MmGgu551gybG2bnR=xR5UoQXjWuKYTA@mail.gmail.com>
On Aug 22, 1:30am, TJ Luoma wrote:
}
} If I know that something it going to happen in 22:05:03 (22hrs 5
} minutes 3 seconds) from now, how do I convert that to a specific time
} like `strftime %Y-%m-%d_%H.%M.%S`?
$((EPOCHSECONDS + 22 * 3600 + 5 * 60 + 3))
Something like
hms2s() {
setopt localoptions no_octal_zeroes
argv[1]=( ${(s.:.)1} )
print $(($1 * 3600 + $2 * 60 + $3))
}
strftime %Y-%m-%d_%H.%M.%S $(( EPOCHSECONDS + $(hms2s 22:05:03) ))
Or you can make a math function:
hms2s() { ((${1:-0} * 3600 + ${2:-0} * 60 + ${3:-0})) }
functions -M hms2s 1 3
strftime %Y-%m-%d_%H.%M.%S $(( EPOCHSECONDS + hms2s(22,5,3) ))
Messages sorted by:
Reverse Date,
Date,
Thread,
Author