Utcnow IsDayLightSaving() problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Varangian

    #1

    Utcnow IsDayLightSaving() problem

    Hello there,

    I'm having a problem with Utcnow property. I'm checking the Utcnow for
    IsDayLightSavin g() if true or false. I'm setting the timezone to GMT
    time London etc and during summer when daylight saving is applied hence
    GMT Daylight time.

    However the System.DateTime .Utcnow.IsDayLi ghtSaving() always returns
    false even when it is on GMT Daylight time. Whats this.. what I'm
    missing?

    Thanks for any insights

  • Jon Skeet [C# MVP]

    #2
    Re: Utcnow IsDayLightSavin g() problem

    Varangian wrote:[color=blue]
    > I'm having a problem with Utcnow property. I'm checking the Utcnow for
    > IsDayLightSavin g() if true or false. I'm setting the timezone to GMT
    > time London etc and during summer when daylight saving is applied hence
    > GMT Daylight time.
    >
    > However the System.DateTime .Utcnow.IsDayLi ghtSaving() always returns
    > false even when it is on GMT Daylight time. Whats this.. what I'm
    > missing?[/color]

    A UTC date-time surely *never* has daylight savings time applied to it,
    by definition. That's what I'd have expected.

    Jon

    Comment

    • Varangian

      #3
      Re: Utcnow IsDayLightSavin g() problem

      The strange thing is when I apply to GMT time zone on my computer and
      set the time a minute before daylight savings apply and wait until the
      minute passes say for example for this year it is on 01:00.... I set it
      to 00:59 and wait until it applies. I see that the time would be 02:00.
      So there seems to be daylight saving in the GMT Time zone. And in fact
      in my code I check by System.DateTime .Now.IsDayLight Saving() and
      returns true.

      strange but true. Thanks Jon Skeet

      Comment

      • Michael Bray

        #4
        Re: Utcnow IsDayLightSavin g() problem

        If I am reading the documentation correctly, the IsDaylightSavin gs() ALWAYS
        returns false if the 'Kind' property of the DateTime is Utc. Thus I would
        think that DateTime.UtcNow .IsDaylightSavi ngs() always returns false,
        whereas DateTime.Now.Is DaylightSavings () might return true if it truly is
        Daylight Savings. The 'Kind' property is new to .NET 2.0, so if you are
        using 1.1 you won't see it, but it still might be there. Try using
        DateTime.Now instead.

        Also, Are you actually setting the time on your computer, or just setting
        the timezone? I would think that your computer time must be set to a
        date/time during which it is ACTUALLY Daylight Savings. We are currently
        on Standard Time (DST runs from early April to late October.)

        -mdb

        "Varangian" <ofmars@gmail.c om> wrote in news:1137422513 .885462.241620
        @g47g2000cwa.go oglegroups.com:
        [color=blue]
        > Hello there,
        >
        > I'm having a problem with Utcnow property. I'm checking the Utcnow for
        > IsDayLightSavin g() if true or false. I'm setting the timezone to GMT
        > time London etc and during summer when daylight saving is applied hence
        > GMT Daylight time.
        >
        > However the System.DateTime .Utcnow.IsDayLi ghtSaving() always returns
        > false even when it is on GMT Daylight time. Whats this.. what I'm
        > missing?
        >
        > Thanks for any insights
        >[/color]

        Comment

        • Varangian

          #5
          Re: Utcnow IsDayLightSavin g() problem

          Thats what I'm doing, I'm actually setting on the windows datetime on
          the taskbar to 26/03/2006 01:59. I thought that Utcnow is the same as
          GMT Time set on the your computer which it seems is not.

          Comment

          • Varangian

            #6
            Re: Utcnow IsDayLightSavin g() problem

            Thats what I'm doing, I'm actually setting on the windows datetime on
            the taskbar to 26/03/2006 01:59. I thought that Utcnow is the same as
            GMT Time set on the your computer which it seems is not.

            Thanks Michael bray

            Comment

            • Jon Skeet [C# MVP]

              #7
              Re: Utcnow IsDayLightSavin g() problem

              Varangian wrote:[color=blue]
              > The strange thing is when I apply to GMT time zone on my computer and
              > set the time a minute before daylight savings apply and wait until the
              > minute passes say for example for this year it is on 01:00.... I set it
              > to 00:59 and wait until it applies. I see that the time would be 02:00.
              > So there seems to be daylight saving in the GMT Time zone. And in fact
              > in my code I check by System.DateTime .Now.IsDayLight Saving() and
              > returns true.[/color]

              Well, I'm in the UK and always pick GMT as my time zone - but
              definitely apply daylight savings. In the summer we're in BST (British
              Summer Time). I suspect there are two sort of parallel considerations
              for GMT going on, effectively. However, UTC is a "constant" - it's GMT
              without daylight savings, effectively. (Actually, I've a suspicion
              there are some subtle differences in terms of leap seconds etc, but
              nothing to worry about.)

              Jon

              Comment

              Working...