* clear out some warnings by gcc 9.3.1.
[alpine.git] / pith / adjtime.c
blobd7769a74ce519fdbb9d68c7077969a7014b4e382
1 #if !defined(lint) && !defined(DOS)
2 static char rcsid[] = "$Id: adjtime.c 761 2007-10-23 22:35:18Z hubert@u.washington.edu $";
3 #endif
5 /*
6 * ========================================================================
7 * Copyright 2013-2020 Eduardo Chappa
8 * Copyright 2006 University of Washington
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * ========================================================================
19 #include "../pith/headers.h"
20 #include "../pith/adjtime.h"
24 * MSC ver 7.0 and less times are since 1900, everybody else's time so far
25 * is since 1970. sheesh.
27 #if defined(DOS) && (_MSC_VER == 700)
28 #define EPOCH_ADJ ((time_t)((time_t)(70*365 + 18) * (time_t)86400))
29 #endif
32 * Adjust the mtime to return time since Unix epoch. DOS is off by 70 years.
34 time_t
35 get_adj_time(void)
37 time_t tt;
39 tt = time((time_t *)0);
41 #ifdef EPOCH_ADJ
42 tt -= EPOCH_ADJ;
43 #endif
45 return(tt);
49 time_t
50 get_adj_name_file_mtime(char *name)
52 time_t mtime;
54 mtime = name_file_mtime(name);
56 #ifdef EPOCH_ADJ
57 if(mtime != (time_t)(-1))
58 mtime -= EPOCH_ADJ;
59 #endif
61 return(mtime);