Printing time in "at" format?

R

Roy Smith

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?
 
T

Tim Chase

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/usr/share/doc/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
 
R

Roy Smith

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.
 
H

Hans Mulder

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top