Printing time in "at" format?

Discussion in 'Python' started by Roy Smith, Nov 20, 2012.

  1. Roy Smith

    Roy Smith Guest

    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?
     
    Roy Smith, Nov 20, 2012
    #1
    1. Advertising

  2. Roy Smith

    Tim Chase Guest

    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/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
     
    Tim Chase, Nov 20, 2012
    #2
    1. Advertising

  3. Roy Smith

    Roy Smith Guest

    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 Smith, Nov 20, 2012
    #3
  4. Roy Smith

    Hans Mulder Guest

    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
     
    Hans Mulder, Nov 21, 2012
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Shaiboy_UK
    Replies:
    0
    Views:
    510
    Shaiboy_UK
    Oct 19, 2003
  2. flamesrock
    Replies:
    8
    Views:
    548
    Hendrik van Rooyen
    Nov 24, 2006
  3. Summu82
    Replies:
    5
    Views:
    899
    Richard Heathfield
    Jun 7, 2006
  4. dch3
    Replies:
    2
    Views:
    525
  5. ruca

    Format textbox to time format

    ruca, May 6, 2005, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    939
    HJohns
    May 9, 2005
Loading...

Share This Page