datetime question

Discussion in 'Python' started by Îίκος Αλεξόπουλος, Nov 8, 2013.

  1. Is there someway to write the following line even better with the
    ability to detect daylight saving time by itself so i don't have to
    alter the line manually when time changes?

    lastvisit = ( datetime.utcnow() + timedelta(hours=2) ).strftime(
    '%y-%m-%d %H:%M:%S' ) # MySQL datetime format

    Thanks.
     
    Îίκος Αλεξόπουλος, Nov 8, 2013
    #1
    1. Advertising

  2. On 08/11/2013 21:11, Îίκος Αλεξόπουλος wrote:
    > Is there someway to write the following line even better with the
    > ability to detect daylight saving time by itself so i don't have to
    > alter the line manually when time changes?
    >
    > lastvisit = ( datetime.utcnow() + timedelta(hours=2) ).strftime(
    > '%y-%m-%d %H:%M:%S' ) # MySQL datetime format
    >
    > Thanks.


    http://stackoverflow.com/questions/...a-timezone-currently-in-daylight-savings-time

    --
    Python is the second best programming language in the world.
    But the best has yet to be invented. Christian Tismer

    Mark Lawrence
     
    Mark Lawrence, Nov 8, 2013
    #2
    1. Advertising

  3. Στις 8/11/2013 11:29 μμ, ο/η Mark Lawrence έγÏαψε:
    > On 08/11/2013 21:11, Îίκος Αλεξόπουλος wrote:
    >> Is there someway to write the following line even better with the
    >> ability to detect daylight saving time by itself so i don't have to
    >> alter the line manually when time changes?
    >>
    >> lastvisit = ( datetime.utcnow() + timedelta(hours=2) ).strftime(
    >> '%y-%m-%d %H:%M:%S' ) # MySQL datetime format
    >>
    >> Thanks.

    >
    > http://stackoverflow.com/questions/...a-timezone-currently-in-daylight-savings-time
    >
    >



    I saw the link and i'm wondering if it can be written in 1-liner.
    Don't get me wrong but i had the lastvisit calculated on 1 statement and
    i want to retain it this way.

    Is it possible?
     
    Îίκος Αλεξόπουλος, Nov 8, 2013
    #3
  4. rurpy? can you help?

    On Fri, Nov 8, 2013 at 5:01 PM, Îίκος Αλεξόπουλος <> wrote:
    > Στις 8/11/2013 11:29 μμ, ο/η MarkLawrence έγÏαψε:
    >>
    >> On 08/11/2013 21:11, Îίκος Αλεξόπουλος wrote:
    >>>
    >>> Is there someway to write the following line even better with the
    >>> ability to detect daylight saving time by itself so i don't have to
    >>> alter the line manually when time changes?
    >>>
    >>> lastvisit = ( datetime.utcnow() + timedelta(hours=2) ).strftime(
    >>> '%y-%m-%d %H:%M:%S' ) # MySQL datetime format
    >>>
    >>> Thanks.

    >>
    >>
    >>
    >> http://stackoverflow.com/questions/...a-timezone-currently-in-daylight-savings-time
    >>
    >>

    >
    >
    > I saw the link and i'm wondering if it can be written in 1-liner.
    > Don't get me wrong but i had the lastvisit calculated on 1 statement and i
    > want to retain it this way.
    >
    > Is it possible?
    > --
    > https://mail.python.org/mailman/listinfo/python-list




    --
    Joel Goldstick
    http://joelgoldstick.com
     
    Joel Goldstick, Nov 8, 2013
    #4
  5. On 2013-11-08, ?????????? ?????????????????????? <> wrote:

    >>> Is there someway to [...]


    >> http://stackoverflow.com/[...]


    > I saw the link and i'm wondering if it can be written in 1-liner.
    > Don't get me wrong but i had the lastvisit calculated on 1 statement
    > and i want to retain it this way.


    It's that global newline shortage again. Just because a few people
    get killed in a newline mine they all go on strike...

    --
    Grant Edwards grant.b.edwards Yow! Mary Tyler Moore's
    at SEVENTH HUSBAND is wearing
    gmail.com my DACRON TANK TOP in a
    cheap hotel in HONOLULU!
     
    Grant Edwards, Nov 8, 2013
    #5
  6. On Sat, Nov 9, 2013 at 9:29 AM, Grant Edwards <> wrote:
    > It's that global newline shortage again. Just because a few people
    > get killed in a newline mine they all go on strike...


    It's a conspiracy! The government kills a few miners (with their
    contrail mind-control stuffo) to push the price of newlines up, then
    taxes us to the hilt and claims it's to fund development of artificial
    newlines in labs! I tell you, man, those artificial newlines may LOOK
    the same, but mark my words, one day they're all gonna rise up and
    murder us in their sleep...

    ChrisA
    been up all night and is starting to get stupid
     
    Chris Angelico, Nov 8, 2013
    #6
  7. On Sat, 09 Nov 2013 00:01:37 +0200, Îίκος Αλεξόπουλος wrote:

    > I saw the link and i'm wondering if it can be written in 1-liner.


    Yes, but you have to rewrite all your code in perl to do this.

    --
    Denis McMahon,
     
    Denis McMahon, Nov 8, 2013
    #7
  8. Στις 9/11/2013 12:49 πμ, ο/η Denis McMahon έγÏαψε:
    > On Sat, 09 Nov 2013 00:01:37 +0200, Îίκος Αλεξόπουλος wrote:
    >
    >> I saw the link and i'm wondering if it can be written in 1-liner.

    >
    > Yes, but you have to rewrite all your code in perl to do this.
    >



    Please tell me and as a git i will provide you with 2 good pdfs i just
    found:

    You can see them at my website if you click the blue download button.

    The 1st is a Linux Bile and the 2nd is WebHosting for Dummies.
     
    Îίκος Αλεξόπουλος, Nov 8, 2013
    #8
  9. Îίκος Αλεξόπουλος

    Robert Kern Guest

    On 2013-11-08 23:02, Îίκος Αλεξόπουλος wrote:
    > Στις 9/11/2013 12:49 πμ, ο/η Denis McMahon έγÏαψε:
    >> On Sat, 09 Nov 2013 00:01:37 +0200, Îίκος Αλεξόπουλος wrote:
    >>
    >>> I saw the link and i'm wondering if it can be written in 1-liner.

    >>
    >> Yes, but you have to rewrite all your code in perl to do this.
    >>

    >
    >
    > Please tell me and as a git i will provide you with 2 good pdfs i just found:
    >
    > You can see them at my website if you click the blue download button.
    >
    > The 1st is a Linux Bile and the 2nd is WebHosting for Dummies.


    Please do not advertise your piracy site here. It is not welcome in this forum.

    --
    Robert Kern

    "I have come to believe that the whole world is an enigma, a harmless enigma
    that is made terrible by our own mad attempt to interpret it as though it had
    an underlying truth."
    -- Umberto Eco
     
    Robert Kern, Nov 8, 2013
    #9
  10. On Sat, Nov 9, 2013 at 10:02 AM, Íßêïò Áëåîüðïõëïò
    <> wrote:
    > Óôéò 9/11/2013 12:49 ðì, ï/ç Denis McMahon Ýãñáøå:
    >
    >> On Sat, 09 Nov 2013 00:01:37 +0200, Íßêïò Áëåîüðïõëïò wrote:
    >>
    >>> I saw the link and i'm wondering if it can be written in 1-liner.

    >>
    >>
    >> Yes, but you have to rewrite all your code in perl to do this.
    >>

    >
    >
    > Please tell me and as a git i will provide you with 2 good pdfs i just
    > found:
    >
    > You can see them at my website if you click the blue download button.
    >
    > The 1st is a Linux Bile and the 2nd is WebHosting for Dummies.


    Interesting. Your idea of a "gift" (quite different from a "git",
    which is grammatically valid in your usage, though not what you
    intended) is to offer something you stole AND which you're already
    giving away to anyone who comes to your web site. This is your
    incentive to us to write your code for you.

    Actually, I think offering people free stolen bile for dummies is a
    great business model. Nobody else is trying that!

    If you want to offer something tempting, it's most likely going to be
    money, and quite a bit of it, as stated in another thread. Plus,
    you'll actually have to respect someone's design choices. Good luck on
    that.

    ChrisA
     
    Chris Angelico, Nov 8, 2013
    #10
  11. On 08/11/2013 23:02, Îίκος Αλεξόπουλος wrote:
    > Στις 9/11/2013 12:49 πμ, ο/η Denis McMahon έγÏαψε:
    >> On Sat, 09 Nov 2013 00:01:37 +0200, Îίκος Αλεξόπουλος wrote:
    >>
    >>> I saw the link and i'm wondering if it can be written in 1-liner.

    >>
    >> Yes, but you have to rewrite all your code in perl to do this.
    >>

    >
    >
    > Please tell me and as a git i will provide you with 2 good pdfs i just
    > found:
    >
    > You can see them at my website if you click the blue download button.
    >
    > The 1st is a Linux Bile and the 2nd is WebHosting for Dummies.


    http://www.cockneyrhymingslang.co.uk/slang/tea_leaf

    --
    Python is the second best programming language in the world.
    But the best has yet to be invented. Christian Tismer

    Mark Lawrence
     
    Mark Lawrence, Nov 9, 2013
    #11
  12. On Sat, Nov 9, 2013 at 11:45 PM, Mark Lawrence <> wrote:
    > Why is Web Security for Dummies missing?


    Because a Dummy can host a web (all you have to do is invite a spider
    into your house and let it do the work), but he won't be able to make
    it secure.

    Or, more succinctly: Because it isn't.

    ChrisA
     
    Chris Angelico, Nov 9, 2013
    #12
  13. Στις 9/11/2013 2:45 μμ, ο/η Mark Lawrence έγÏαψε:
    > On 08/11/2013 23:02, Îίκος Αλεξόπουλος wrote:
    >> Στις 9/11/2013 12:49 πμ, ο/η Denis McMahon έγÏαψε:
    >>> On Sat, 09 Nov 2013 00:01:37 +0200, Îίκος Αλεξόπουλος wrote:
    >>>
    >>>> I saw the link and i'm wondering if it can be written in 1-liner.
    >>>
    >>> Yes, but you have to rewrite all your code in perl to do this.
    >>>

    >>
    >>
    >> Please tell me and as a git i will provide you with 2 good pdfs i just
    >> found:
    >>
    >> You can see them at my website if you click the blue download button.
    >>
    >> The 1st is a Linux Bile and the 2nd is WebHosting for Dummies.

    >
    > Why is Web Security for Dummies missing?
    >



    It's not missing.
    Its there, check again.
    Just click on the Blue download button and select it from the list of
    buttons.
     
    Îίκος Αλεξόπουλος, Nov 9, 2013
    #13
  14. Îίκος Αλεξόπουλος

    Roy Smith Guest

    In article <>,
    Chris Angelico <> wrote:

    > On Sat, Nov 9, 2013 at 9:29 AM, Grant Edwards <> wrote:
    > > It's that global newline shortage again. Just because a few people
    > > get killed in a newline mine they all go on strike...

    >
    > It's a conspiracy! The government kills a few miners (with their
    > contrail mind-control stuffo) to push the price of newlines up, then
    > taxes us to the hilt and claims it's to fund development of artificial
    > newlines in labs! I tell you, man, those artificial newlines may LOOK
    > the same, but mark my words, one day they're all gonna rise up and
    > murder us in their sleep...


    I only use organic, free-range, fair-traded newlines in my code. Have
    you ever seen what happens on those big commercial whitespace farms?
    The newlines are kept in justified lines, smashed up against the right
    margin so close they can't even move, and forced to eat recycled EBCDIC
    punctuation!
     
    Roy Smith, Nov 9, 2013
    #14
  15. Îίκος Αλεξόπουλος

    Gene Heskett Guest

    On Saturday 09 November 2013 10:33:57 Chris Angelico did opine:

    > On Sat, Nov 9, 2013 at 9:29 AM, Grant Edwards <>

    wrote:
    > > It's that global newline shortage again. Just because a few people
    > > get killed in a newline mine they all go on strike...

    >
    > It's a conspiracy! The government kills a few miners (with their
    > contrail mind-control stuffo) to push the price of newlines up, then
    > taxes us to the hilt and claims it's to fund development of artificial
    > newlines in labs! I tell you, man, those artificial newlines may LOOK
    > the same, but mark my words, one day they're all gonna rise up and
    > murder us in their sleep...
    >
    > ChrisA
    > been up all night and is starting to get stupid


    Ya know, folks like Nick would have me signing off. Fortunately there are
    kill files. But the backscatter he creates I am still forced to read, or
    more usually skip.

    This list recently has been far more about venting because GG is broken, or
    Nicks un-teachability than about real code, by a large margin.

    Then one of you frustrated standup comics comes along, and gives me a VBG,
    and its suddenly all worth it. Thank You Chris.

    Cheers, Gene
    --
    "There are four boxes to be used in defense of liberty:
    soap, ballot, jury, and ammo. Please use in that order."
    -Ed Howdershelt (Author)

    Hark, the Herald Tribune sings,
    Advertising wondrous things.

    Angels we have heard on High
    Tell us to go out and Buy.
    -- Tom Lehrer
    A pen in the hand of this president is far more
    dangerous than 200 million guns in the hands of
    law-abiding citizens.
     
    Gene Heskett, Nov 9, 2013
    #15
  16. On Sun, Nov 10, 2013 at 2:39 AM, Gene Heskett <> wrote:
    > Ya know, folks like Nick would have me signing off. Fortunately there are
    > kill files. But the backscatter he creates I am still forced to read, or
    > more usually skip.
    >
    > Then one of you frustrated standup comics comes along, and gives me a VBG,
    > and its suddenly all worth it. Thank You Chris.


    :) Don't just thank me, Grant and Roy were key to it too - and the
    whole "there's no shortage of newlines" thing started with Steven
    D'Aprano (I think), and it's a ripe field for harvest :)

    But hey. If you're going to have to read backscatter, may as well make
    it funny...

    ChrisA
     
    Chris Angelico, Nov 9, 2013
    #16
  17. Îίκος Αλεξόπουλος

    Gene Heskett Guest

    On Saturday 09 November 2013 19:52:52 Chris Angelico did opine:

    > On Sun, Nov 10, 2013 at 2:39 AM, Gene Heskett <> wrote:
    > > Ya know, folks like Nick would have me signing off. Fortunately there
    > > are kill files. But the backscatter he creates I am still forced to
    > > read, or more usually skip.
    > >
    > > Then one of you frustrated standup comics comes along, and gives me a
    > > VBG, and its suddenly all worth it. Thank You Chris.

    > :
    > :) Don't just thank me, Grant and Roy were key to it too - and the
    >
    > whole "there's no shortage of newlines" thing started with Steven
    > D'Aprano (I think), and it's a ripe field for harvest :)


    And likely not fully gleaned yet. :) To all of you, thats some of the
    better creative writing I've read in my 79 years. ;-)

    > But hey. If you're going to have to read backscatter, may as well make
    > it funny...


    Precisely.

    > ChrisA



    Cheers, Gene
    --
    "There are four boxes to be used in defense of liberty:
    soap, ballot, jury, and ammo. Please use in that order."
    -Ed Howdershelt (Author)

    A Difficulty for Every Solution.
    -- Motto of the Federal Civil Service
    A pen in the hand of this president is far more
    dangerous than 200 million guns in the hands of
    law-abiding citizens.
     
    Gene Heskett, Nov 10, 2013
    #17
  18. On Sun, Nov 10, 2013 at 11:55 AM, Gene Heskett <> wrote:
    > On Saturday 09 November 2013 19:52:52 Chris Angelico did opine:
    >> :) Don't just thank me, Grant and Roy were key to it too - and the
    >> whole "there's no shortage of newlines" thing started with Steven
    >> D'Aprano (I think), and it's a ripe field for harvest :)

    >
    > And likely not fully gleaned yet. :) To all of you, thats some of the
    > better creative writing I've read in my 79 years. ;-)


    Are you going to have a newyear after next year and start over with
    Year 1 again?

    ChrisA
     
    Chris Angelico, Nov 10, 2013
    #18
  19. Îίκος Αλεξόπουλος

    Gene Heskett Guest

    On Sunday 10 November 2013 04:06:06 Chris Angelico did opine:

    > On Sun, Nov 10, 2013 at 11:55 AM, Gene Heskett <> wrote:
    > > On Saturday 09 November 2013 19:52:52 Chris Angelico did opine:
    > >> :) Don't just thank me, Grant and Roy were key to it too - and the
    > >>
    > >> whole "there's no shortage of newlines" thing started with Steven
    > >> D'Aprano (I think), and it's a ripe field for harvest :)

    > >
    > > And likely not fully gleaned yet. :) To all of you, thats some of the
    > > better creative writing I've read in my 79 years. ;-)

    >
    > Are you going to have a newyear after next year and start over with
    > Year 1 again?
    >

    Nah. I tried to put it off as long as I could, but times arrow, dammit,
    only points forward. I might as well get used to it. From that famous
    line about death and taxes, taxes will of course outlive me. Being a DM-II,
    I of course haven't a shred of warranty left. Just up to pee and check on
    that falling satellite, I could fall over walking the 20 feet back to bed,
    but I'm going to do it anyway... ;-)

    > ChrisA



    Cheers, Gene
    --
    "There are four boxes to be used in defense of liberty:
    soap, ballot, jury, and ammo. Please use in that order."
    -Ed Howdershelt (Author)

    $100 invested at 7% interest for 100 years will become $100,000, at
    which time it will be worth absolutely nothing.
    -- Lazarus Long, "Time Enough for Love"
    A pen in the hand of this president is far more
    dangerous than 200 million guns in the hands of
    law-abiding citizens.
     
    Gene Heskett, Nov 10, 2013
    #19
  20. Στις 8/11/2013 11:11 μμ, ο/η Îίκος Αλεξόπουλος έγÏαψε:
    > Is there someway to write the following line even better with the
    > ability to detect daylight saving time by itself so i don't have to
    > alter the line manually when time changes?
    >
    > lastvisit = ( datetime.utcnow() + timedelta(hours=2) ).strftime(
    > '%y-%m-%d %H:%M:%S' ) # MySQL datetime format
    >
    > Thanks.



    Someone has an idea what to add to this line to automatically adjust
    itself if DST happens?
     
    Îίκος Αλεξόπουλος, Nov 11, 2013
    #20
    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. Christos TZOTZIOY Georgiou
    Replies:
    3
    Views:
    743
    Christos TZOTZIOY Georgiou
    Sep 13, 2003
  2. Tim Peters
    Replies:
    0
    Views:
    578
    Tim Peters
    Sep 9, 2003
  3. mp
    Replies:
    1
    Views:
    415
    John Machin
    Jul 28, 2006
  4. Martin
    Replies:
    0
    Views:
    361
    Martin
    Dec 27, 2008
  5. Replies:
    2
    Views:
    786
    M.-A. Lemburg
    Jan 6, 2009
Loading...

Share This Page