3 Replies Latest reply on Nov 16, 2020 9:56 AM by LePo_1062026

    Unix Time To mm:dd:yy hh:mm?

    EdHa_4455331

      Are there any library functions in the Creator ecosystem for extracting year, month, day, hours, minutes, seconds from a 32-bit unix time?

       

      Thanks,

       

      Ed H.

        • 1. Re: Unix Time To mm:dd:yy hh:mm?
          LePo_1062026

          Ed,

           

          There are Unix time to yy:mm:dd hh:mm:ss source code available on the internet.

           

          I've created my own version of it that minimizes month calculation iterations. (It assumes no Unix Time values are earlier than Jan 1, 2020.)

           

          If you're looking to convert UTP via NTP servers, I believe there is at least one example project for the PSoC6.

           

          Len

          • 2. Re: Unix Time To mm:dd:yy hh:mm?
            EdHa_4455331

            If the routine is part of a built-in library I can probably get by without having to include it in the formal verification for my project. If I pull in source code of unknown providence (FDA terminology) I do. So I was hoping for a built in solution.

             

            I also have looked out in the internet for a straight forward c language conversion routine. The internet is now so cluttered it is harder to find such an routine than you might think. Since I won't permit dates earlier than Jan 1, 2020, I could use your version. Can you post a link to it? Or just paste it in a reply?

             

            Thanks,

             

            Ed H.

            • 3. Re: Unix Time To mm:dd:yy hh:mm?
              LePo_1062026

              Ed,

               

              I looked back at my code archives.  I think I abandoned my UTC processing.  I ended up using the following code.

              I converted this code from C++ code to C.  Hopefully it works.  Either way it's a start.

               

              It's time starting reference is Jan 1, 1970.

               

              Len

               

              PS:  Just test the parseTime() function.  It works.

              Note the following:

              • The Year field is the years since 1970.
              • There is no Daylight Savings Time correction.
              • There is no time zone correction.