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

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
EdHa_4455331
Level 5
Level 5
25 replies posted 25 sign-ins 10 replies posted

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.

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.

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.
Len
"Engineering is an Art. The Art of Compromise."

View solution in original post

0 Likes
3 Replies
Len_CONSULTRON
Level 9
Level 9
Beta tester 500 solutions authored 1000 replies posted

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

Len
"Engineering is an Art. The Art of Compromise."
0 Likes

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.

0 Likes
lock attach
Attachments are accessible only for community members.

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.
Len
"Engineering is an Art. The Art of Compromise."
0 Likes