| 1 | /* Minimal localtime_r implementation (not reentrant though). |
| 2 | * This file is in the public domain. |
| 3 | * |
| 4 | * Call localtime and if it succeeds copy the contents of the |
| 5 | * localtime's static tm structure into the caller's structure. |
| 6 | */ |
| 7 | |
| 8 | #include <errno.h> |
| 9 | #include <time.h> |
| 10 | |
| 11 | struct tm * |
| 12 | localtime_r(const time_t *t, struct tm *ptm) |
| 13 | { |
| 14 | struct tm *ptms = localtime(t); /* pointer to static structure */ |
| 15 | |
| 16 | if (ptms) |
| 17 | { |
| 18 | *ptm = *ptms; |
| 19 | return ptm; |
| 20 | } |
| 21 | else |
| 22 | { |
| 23 | return 0; |
| 24 | } |
| 25 | } |