Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   Printing time in "at" format? (http://www.velocityreviews.com/forums/t954675-printing-time-in-at-format.html)

Roy Smith 11-20-2012 04:18 PM

Printing time in "at" format?
 
I need to talk to an API which requires (for reasons totally beyond my
comprehension), time specified in "at" format, i.e. the format
accepted by the unix "at" command. This allows you to do such bizarre
things as use "teatime" to indicate 4:00 PM. The best I can find for
a specification is http://tinyurl.com/d5vddoa.

Before I dive into this too far, has anybody already written some code
which formats times like that?

Tim Chase 11-20-2012 06:16 PM

Re: Printing time in "at" format?
 
On 11/20/12 10:18, Roy Smith wrote:
> I need to talk to an API which requires (for reasons totally beyond my
> comprehension), time specified in "at" format, i.e. the format
> accepted by the unix "at" command. This allows you to do such bizarre
> things as use "teatime" to indicate 4:00 PM. The best I can find for
> a specification is http://tinyurl.com/d5vddoa.
>
> Before I dive into this too far, has anybody already written some code
> which formats times like that?


Your statement can be ambiguously parsed as "I need to merely
*generate* time specifications that 'at' can parse", or it can be
parsed as "I need to generate *and consume* time specifications the
same way as 'at' does"

If it's the former, it's pretty easy--'at' accepts a wide variety of
formats.

If it's the latter, I've got a doc in

/usr/share/doc/at/timespec

on my Debian machine, which seems to be googleable, but here's one
copy of it

http://fts.ifac.cnr.it/cgi-bin/dwww/...oc/at/timespec

I don't have a parser already, but that should get you a jump start
on what (at least Debian's) 'at' parses, and might tie nicely with
pyparsing.

-tkc



Roy Smith 11-20-2012 06:24 PM

Re: Printing time in "at" format?
 
On Nov 20, 2012, at 1:16 PM, Tim Chase wrote:

> Your statement can be ambiguously parsed as "I need to merely
> *generate* time specifications that 'at' can parse", or it can be
> parsed as "I need to generate *and consume* time specifications the
> same way as 'at' does"
>
> If it's the former, it's pretty easy--'at' accepts a wide variety of
> formats.


Fortunately, it's the former.

Since posting my original query, I have discovered by experimentation that the API also accepts a string of digits as a unix timestamp, so this turns out to be trivial.

---
Roy Smith
roy@panix.com




Hans Mulder 11-21-2012 12:14 PM

Re: Printing time in "at" format?
 
On 20/11/12 17:18:33, Roy Smith wrote:
> I need to talk to an API which requires (for reasons totally beyond my
> comprehension), time specified in "at" format, i.e. the format
> accepted by the unix "at" command. This allows you to do such bizarre
> things as use "teatime" to indicate 4:00 PM. The best I can find for
> a specification is http://tinyurl.com/d5vddoa.
>
> Before I dive into this too far, has anybody already written some code
> which formats times like that?


On my machine x.strftime("%H:%m %d.%m.%Y") formats datetime objects
in a format that at(1) understands:

$ > at -f my_job '12:11 21.11.2012'
at: trying to travel back in time


Hope this helps,

-- HansM


All times are GMT. The time now is 08:35 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.