Calculating Daylight Saving Time


Closed Thread
Results 1 to 20 of 20

Hybrid View

  1. #1
    Join Date
    Jul 2003
    Location
    Lancashire
    Posts
    50


    Did you find this post helpful? Yes | No

    Default Re: Calculating Daylight Saving Time

    Hi Heckler


    So how do you translate this bit of code into PICbasic??
    DSTStart = (31 - (((5*Year)/4)+ 4) mod 7)

    The whole subroutine is cut directly from my PBP program and will work as is. If you want to check it write it as a small program, set Year word variable to 2016 and debug out the start and end dates.
    Cheers Pete

  2. #2
    Join Date
    Oct 2009
    Location
    Utah, USA
    Posts
    427


    Did you find this post helpful? Yes | No

    Default Re: Calculating Daylight Saving Time

    @Pete,

    I'll give it a try.
    I scanned through my PBP3 manual and could not find "MOD" anywhere. It doesn't show in the reserved word list either.

    From the link that Pedja089 posted...
    USA starting in 2007, extended DST to
    begin on the 2nd Sunday in March (Day of month = 14 - (1+Y*5/4) mod 7)
    and end on the 1st Sunday in November (Day of month = 7 - (1 + 5*Y/4) mod 7).

    For Europe...
    DST begins on the last Sunday in March (Day of month = 31 - (4+ 5*Y/4 ) mod 7)
    and ends on the last Sunday in October (Day of month = 31 - (1 + 5*Y/4) mod 7)
    Dwight
    These PIC's are like intricate puzzles just waiting for one to discover their secrets and MASTER their capabilities.

  3. #3
    Join Date
    Aug 2008
    Location
    Portugal
    Posts
    240


    Did you find this post helpful? Yes | No

    Default Re: Calculating Daylight Saving Time

    // Remainder (Modulus)
    Thanks and Regards;
    Gadelhas

  4. #4
    Join Date
    Jul 2003
    Location
    Lancashire
    Posts
    50


    Did you find this post helpful? Yes | No

    Default Re: Calculating Daylight Saving Time

    Hi

    I think it depends on the manual you have, mine has MOD as a reserved word in it but an earlier version does not.
    Cheers Pete

  5. #5
    Join Date
    Oct 2009
    Location
    Utah, USA
    Posts
    427


    Did you find this post helpful? Yes | No

    Default Re: Calculating Daylight Saving Time

    If anyone is wondering...

    My code above does seem to test out working.
    I modified my clock code to temporarily change the time to Sun March 13 01:59:45 (15 sec before DST should start) and then watched it change from 01:59 to 03:00 as it was supposed to.

    Then I changed the time to Sun Nov 06 01:59:45 and watched it change from 01:59 to 01:00 as it should.

    My nixie clock checks the date and time every morning at 05:00 and then calls my routine to test if STD/DST is in effect.
    So over the next year it will be tested thoroughly.

    In my case the nixie display is turned off between 10 pm and 6 am but it is still keeping time.

    I'll have to ponder how to implement the above calculations into my overall code as I think I would still need to do a comparison between the current date and the calculated Start/End of DST.

    I can't just abandon my baby (my version of the code) as I slaved over it for several hours
    and it was a great challenge (as all code writing is)

    But I will ponder implementing the apparently more simpler version in the near future.

    thanks everyone
    Dwight
    These PIC's are like intricate puzzles just waiting for one to discover their secrets and MASTER their capabilities.

  6. #6
    Join Date
    Aug 2008
    Location
    Portugal
    Posts
    240


    Did you find this post helpful? Yes | No

    Default Re: Calculating Daylight Saving Time

    Dwight

    How are you getting the time? GPS?
    Thanks and Regards;
    Gadelhas

  7. #7
    Join Date
    Oct 2009
    Location
    Utah, USA
    Posts
    427


    Did you find this post helpful? Yes | No

    Default Re: Calculating Daylight Saving Time

    gadelhas,

    from an ESP8266-01 wifi module.
    Which is an amazing little wifi module that is connected to my home LAN.

    check out my clock project here...
    http://www.picbasic.co.uk/forum/showthread.php?t=20965

    and check out my description of the ESP8266-01 module here...
    http://www.picbasic.co.uk/forum/showthread.php?t=20957

    The little ESP module is incredibly easy to work with and really interfaces to the PIC quite easily.

    If you have more questions feel free to ask or PM me.
    Dwight
    These PIC's are like intricate puzzles just waiting for one to discover their secrets and MASTER their capabilities.

  8. #8
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: Calculating Daylight Saving Time

    Unless you have a calendar you’d still want the data table anyway.
    Any time you want to add or subtract time you need a calendar.

    If the clock retrieves UTC time as 00:01 1st Jan 2016, and has to subtract one hour.
    It has to know right down to days in month, leap years, the whole lot.

Similar Threads

  1. Calculating time delay between two inputs?
    By grimmjow in forum General
    Replies: 11
    Last Post: - 18th October 2010, 15:52
  2. Calculating Time for clock's preset
    By menta in forum General
    Replies: 33
    Last Post: - 5th July 2008, 07:09
  3. Calculating elapsed time, how?
    By Eng4444 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 1st June 2006, 10:00
  4. FYI Daylight Saving Time in the U.S.
    By ccsparky in forum General
    Replies: 1
    Last Post: - 7th November 2005, 16:05
  5. Sinus calculating !
    By Don Mario in forum mel PIC BASIC Pro
    Replies: 29
    Last Post: - 29th November 2004, 00:56

Members who have read this thread : 2

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts