pnggroup / libpng

LIBPNG: Portable Network Graphics support, official libpng repository
http://libpng.sf.net
Other
1.29k stars 626 forks source link

libpng 1.7: Replacement for png_convert_from_time_t #278

Open ax3l opened 5 years ago

ax3l commented 5 years ago

With png_convert_from_time_t and png_convert_from_struct_tm being deprecated in the upcoming 1.7 branch, what are the recommended replacements for those?

Introduced in: https://github.com/glennrp/libpng/commit/4cc89fb733bed1bc2d96953e997da114258e3d1f

jbowler commented 3 months ago

png_convert_from_time_t: gmtime png_convert_from_struct_tm: use struct tm, not png_time_t

jbowler commented 2 months ago

Better: use gmtime_s, but that requires C11.

I think it could be done in libpng 1.8 in a C89/C90/C99 compatible way with something like:

typedef struct tm png_time;
....
#define png_convert_from_struct_tm(p, t) (*(p) = *(t))
#define png_convert_from_time_t(p, t) (*(p) = *gmtime(&(t)))

It might also be necessary to include The above should produce the appropriate warnings from more modern compilers (because they know gmtimeis not thread safe) whereas at present there are no warnings.