temporary commit while I update master
[alpine.git] / pith / adjtime.c
blobf8d1a4abbe7322cbb430287fee1bab7916dbb30a
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-2017 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);