Calculating Daylight Saving Time


Closed Thread
Results 1 to 20 of 20

Hybrid View

  1. #1
    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.

  2. #2
    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

  3. #3
    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.

  4. #4
    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.

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


    Did you find this post helpful? Yes | No

    Default Re: Calculating Daylight Saving Time

    Quote Originally Posted by Art View Post
    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.
    It's for this reason that is better work with epochtime.
    Thanks and Regards;
    Gadelhas

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


    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.
    In my case I don't care about the date or year etc (other than to be used in the calculation to determine if DST is in effect or not)
    and my code does not require the year for the calculation. I just needed the month, date and day of week to run through my algorithm.

    My clock simply displays HH:MM, the seconds are still tracked to know when to increment the minutes.

    My code checks NTP time twice a day (at 0500 and 1500) and runs the calc.
    The reason I don't check it 12 hours apart is because I want it to be most accurate first thing in the morning and when I get home from work.
    The display is blank between 2200 and 0600.

    As noted above the ESP module give me the time in STD time and then my code determines if I need to add 1 hour or leave the time as is.

    So far it seems to be working correctly.
    Dwight
    These PIC's are like intricate puzzles just waiting for one to discover their secrets and MASTER their capabilities.

  7. #7
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: Calculating Daylight Saving Time

    Dwight, Here is the code I flashed into the ESP8266-01 I use for NTP time service. It is NOT ESP8266Basic but the standard AT command set with an added set of commands to interface with the NTP pool.org for the NTP service. It also allows for all of the other AT commands to be used. I found the ESP8255Basic to be too unstable.
    Attached Files Attached Files
    Dave Purola,
    N8NTA
    EN82fn

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


    Did you find this post helpful? Yes | No

    Default Re: Calculating Daylight Saving Time

    @Art
    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.
    In my case, my clock does not keep track of the date or year.
    I only use the Day of Week, Month and Date to determine if DST is or is not in effect.

    My ESP module gives me those three items along with the HH:MM:SS and my algorithm then determines whether or not I need to add 1 hour to the provided STD time. After that I don't bother with anything other than HH:MM:SS.

    My code above seems to be working good so far and I did test for DST/STD crossing in both directions and it seems to work.

    @Dave
    Thanks for sharing your code, I'll take a look at it.

    So far my module running ESPbasic has been running solid with this code loaded in the ESP module...
    '================================================= ==========
    '--- This is the code running on the ESP8266-01 module ---
    '================================================= ==========
    '''memclear
    '''cls
    '''timesetup(-7,0)
    '''baudrate 9600
    '''serialtimeout 2000
    '''delay 1000
    '''button "Exit" [Exit]
    '''timer 100 [PicSer]
    '''wait
    ''''
    '''[PicSer]
    '''serialflush
    '''input picin
    '''picin = mid(picin,1,5)
    '''if picin == "Time?" then gosub [gettime]
    '''wait
    ''''
    '''[gettime]
    '''bla = time()
    '''dy = mid(bla,1,3) 'dow
    '''mh = mid(bla,5,3) 'month
    '''dd = mid(bla,9,2) 'date
    '''hh = mid(bla,12,2) 'hour
    '''mm = mid(bla,15,2) 'min
    '''ss = mid(bla,18,2) 'sec
    '''yr = mid(bla,21,4) 'year
    ''''
    '''if dy == "Sun" then dow = "1/"
    '''if dy == "Mon" then dow = "2/"
    '''if dy == "Tue" then dow = "3/"
    '''if dy == "Wed" then dow = "4/"
    '''if dy == "Thu" then dow = "5/"
    '''if dy == "Fri" then dow = "6/"
    '''if dy == "Sat" then dow = "7/"
    ''''
    '''if mh == "Jan" then mth = "01/"
    '''if mh == "Feb" then mth = "02/"
    '''if mh == "Mar" then mth = "03/"
    '''if mh == "Apr" then mth = "04/"
    '''if mh == "May" then mth = "05/"
    '''if mh == "Jun" then mth = "06/"
    '''if mh == "Jul" then mth = "07/"
    '''if mh == "Aug" then mth = "08/"
    '''if mh == "Sep" then mth = "09/"
    '''if mh == "Oct" then mth = "10/"
    '''if mh == "Nov" then mth = "11/"
    '''if mh == "Dec" then mth = "12/"
    ''''
    '''picout = dow & mth
    '''picout = picout & dd
    '''picout = picout & "/"
    '''picout = picout & hh
    '''picout = picout & mm
    '''picout = picout & ss
    ''''
    '''serialprintln picout
    '''return
    ''''
    '''[Exit]
    '''end
    If you want to see the code running on the PIC in the clock just search the forum for "nixie".

    I wonder if you were having problems with a certain version of the ESPbasic OS. Mike did seem to have a couple of versions that were a bit unreliable.

    My ESP module is currently running Version 1.67 of the OS. I think he is up over 1.8x now and I think it is working pretty well also.
    I think the problems were in the 1.7x region of his revisions. (not exact)

    The ESPbasic is based (I believe) on the arduion IDE and the arduino/ESP foundation so if you are competent at the arduino C-like language then that is probably a good way to go.

    I just like the built in IDE of the ESPbasic and it's (for me) easy to understand and no external IDE required.

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

Similar Threads

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

Members who have read this thread : 7

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