Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Perl daylight savings time issue? (nm, I'm an idiot)

by cLive ;-) (Prior)
on Mar 14, 2016 at 14:30 UTC ( #1157650=perlquestion: print w/replies, xml ) Need Help??

cLive ;-) has asked for the wisdom of the Perl Monks concerning the following question:

perl -MData::Dumper -e "print Dumper(localtime()),$/"

$isdst (last element) is true, when it should be false.

date +%Z

correctly shows EDT. Am I missing something, or is this an issue?

EDIT: NM. I always though Daylight Savings Time was winter. Apparently it's Summer... heh

Replies are listed 'Best First'.
Re: Perl daylight savings time issue?
by choroba (Archbishop) on Mar 14, 2016 at 14:38 UTC
    What does $ENV{TZ} say?
    TZ='America/New_York' perl -wE 'print +(localtime)[-1]' 1

    Why should it be false if the "D" stands for Daylight in "Eastern Daylight Time"?

    ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

      Setting TZ env var makes no difference.

      "$isdst is true if the specified time occurs during Daylight Saving Time, false otherwise."

Re: Perl daylight savings time issue? (nm, I'm an idiot)
by CountZero (Bishop) on Mar 14, 2016 at 15:58 UTC
    In Belgium Daylight Saving Time starts on Sunday March 27, 2016 at 2:00 AM local time.

    Hence perl -MData::Dumper -le "print [ localtime() ]->[-1]" now gives 0 and perl -MData::Dumper -le "print [ localtime(time + 60 * 60 * 24 * 14) ]->[-1]" gives 1.

    My Windows 7 computer doesn't have a TZ environment variable set at all.

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

    My blog: Imperial Deltronics
Re: Perl daylight savings time issue?
by 1nickt (Canon) on Mar 14, 2016 at 14:37 UTC

    Hi cLive ;-),

    I get the same output on my host machine (OS X) which is set to PDT, but I get $isdst value of 0 on the VM (Ubuntu), which is in UTC.

    Hope this helps!


    The way forward always starts with a minimal test.
Re: Perl daylight savings time issue? (nm, I'm an idiot)
by GrandFather (Saint) on Mar 14, 2016 at 19:45 UTC
    EDIT: NM. I always though Daylight Savings Time was winter. Apparently it's Summer... heh

    The winter equivalent is "Night Time Savings". Night Time Savings time of year is of special interest to ground based visible and near visible light astronomers.

    Premature optimization is the root of all job security
Re: Perl daylight savings time issue?
by Your Mother (Archbishop) on Mar 14, 2016 at 15:04 UTC

    Shows true here.

    moo@cow[3595]~>perl -MData::Dumper -le "print [ localtime() ]->[-1]" 1

    Probably your box has a setting to use/respect DST and it's not on/configured?

      It should be false though, because we are not under Daylight Savings Time any more.

        I'm gonna say the $isdst understanding is backwards? Last week it was zero–

        perl -MData::Dumper -le "print [ localtime(time - 60 * 60 * 24 * 7) ]- +>[-1]" 0

        Update: Google on search: Daylight Saving Time (United States) 2016 began at 2:00 AM on Sunday, March 13 and ends at 2:00 AM on Sunday, November 6

        Oh, I'm sorry. I totally misread the OP. :(

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1157650]
Approved by Lady_Aleena
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2022-09-25 20:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer my indexes to start at:




    Results (116 votes). Check out past polls.

    Notices?