GMT to Local Time Routine


Closed Thread
Results 1 to 15 of 15

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default Re: GMT to Local Time Routine

    Quote Originally Posted by Art View Post
    In Eastern Australia we are +10.

    You are lucky if you are only displaying 24 hour time, and not the date,
    or you need a full calendar all the way to checking leap years.
    Just the one hour ahead the hour before midnight on a New Year’s Eve,
    would make the entire date and day of week incorrect otherwise.
    Thats why its better working with EpochTime.
    Thanks and Regards;
    Gadelhas

  2. #2
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: GMT to Local Time Routine

    How do you not still need a calendar?.. You can calculate all you want from an epoch moment,
    how do you then know the day of week, or if a date such as the 45th of June 1955 is invalid?
    The calendar still counts from an epoch... you need to begin with a known leap year.

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


    Did you find this post helpful? Yes | No

    Default Re: GMT to Local Time Routine

    Quote Originally Posted by Art View Post
    How do you not still need a calendar?.. You can calculate all you want from an epoch moment,
    how do you then know the day of week, or if a date such as the 45th of June 1955 is invalid?
    The calendar still counts from an epoch... you need to begin with a known leap year.
    Hi Art;

    The Epoch/Unix time ( 32 bits ) its valid since 1970 to 1938. Probably it will be changed to 64bits and then it will be valid longer than the age of the universe. ( Probably )

    Several Industrial systems and Computer systems uses this aproach.
    You don't need a calender for nothing, you can calculate everything from epoch time, including day of week, and also if a some date is valid or not.
    By the way , to calculate day of week, or leap year you don't even need epoch time.

    References;

    Epoch/Unix time - https://en.wikipedia.org/wiki/Unix_time
    Day of week calculation - https://en.wikipedia.org/wiki/Determ...ay_of_the_week

    Calculating leap year. ( the algorith that i use ) You can find others;
    if((year % 4 == 0) && (year % 100 != 0) || (year % 400 == 0))
    {
    isleapyear;
    }
    else
    {
    isnotleapyear;
    }

    Videos;
    Thanks and Regards;
    Gadelhas

  4. #4
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: GMT to Local Time Routine

    This sounds like exactly what I did.. an maybe just that I call the code a calendar.
    Except that I have a lookup table of leap years and start the algorithm from the closest to current.
    Actually, thinking again, it might have been dates known to be a Monday on the first day.

Similar Threads

  1. local exchanges
    By datacomms in forum Ethernet
    Replies: 1
    Last Post: - 28th March 2022, 22:21
  2. Simple "Time-out" routine
    By JacoMuller in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 4th May 2010, 09:16
  3. Internet-Ethernet and Local Net
    By Ioannis in forum General
    Replies: 15
    Last Post: - 7th January 2008, 21:16
  4. local variables
    By BigWumpus in forum PBP Wish List
    Replies: 2
    Last Post: - 10th April 2006, 23:39
  5. RTC 1302 !!! Set time Routine !!
    By uludere72 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 24th February 2006, 09:28

Members who have read this thread : 0

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

Tags for this Thread

Posting Permissions

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