Some fixes found by cppcheck.
[ttfautohint.git] / lib / tatime.c
blobf8a1ff0155ce871e623daf4de91888d60b628b47
1 /* tatime.c */
3 /*
4 * Copyright (C) 2011-2019 by Werner Lemberg.
6 * This file is part of the ttfautohint library, and may only be used,
7 * modified, and distributed under the terms given in `COPYING'. By
8 * continuing to use, modify, or distribute this file you indicate that you
9 * have read `COPYING' and understand and accept it fully.
11 * The file `COPYING' mentioned in the previous paragraph is distributed
12 * with the ttfautohint library.
16 #include <time.h>
18 #include "ta.h"
21 void
22 TA_get_current_time(FONT* font,
23 FT_ULong* high,
24 FT_ULong* low)
26 /* there have been 24107 days between January 1st, 1904 (the epoch of */
27 /* OpenType), and January 1st, 1970 (the epoch of the `time' function) */
28 const unsigned long long seconds_to_1970 = 24107 * 24 * 60 * 60;
29 unsigned long long seconds_to_today = seconds_to_1970;
32 if (font->epoch != ULLONG_MAX)
33 // we don't take care of potential overflow
34 seconds_to_today += font->epoch;
35 else
36 seconds_to_today += (unsigned long long)time(NULL);
38 *high = (FT_ULong)(seconds_to_today >> 32);
39 *low = (FT_ULong)seconds_to_today;
42 /* end of tatime.c */