Reputation: 189686
I'm working on microcontroller w/ a primitive standard library, and I need to convert a calendar time structure to a time-offset-from-epoch and back, ala struct tm
<-> time_t
. There's no built-in function available to do this.
Could anyone refer me to a decent implementation which is open-source licensed, usable in proprietary software? (i.e. non-LGPL/GPL)
I can probably write one on my own but figured I should see if I can get a head start.
Upvotes: 3
Views: 2432
Reputation: 15944
Newlib is a non-GPL implementation of the standard library intended for embedded devices. It contains a mktime
call. Some of the files within are GPL, however, so be careful which ones you utilize (full licensing terms).
I'm a big proponent in embedded work of not reinventing the standard library. You'll undoubtedly need more of it than just mktime
, so it might be worth looking into.
Upvotes: 4
Reputation: 182649
I was just thinking that BSDs use their own libc
when Neil Butterworth commented. Look in lib/libc/stdtime/localtime.c
for mktime
and time1
. You should be able to rip time1
without problems.
Here it is: src/lib/libc/stdtime/Attic/localtime.c
Upvotes: 5