 c474b5cea4
			
		
	
	c474b5cea4
	
	
	
		
			
			git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@1841 ec53bebd-3082-4978-b11e-865c3cabbd6b
		
			
				
	
	
		
			38 lines
		
	
	
		
			666 B
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			38 lines
		
	
	
		
			666 B
		
	
	
	
		
			C
		
	
	
	
	
	
| #include "asn1_locl.h"
 | |
| 
 | |
| RCSID("$Id$");
 | |
| 
 | |
| #ifndef HAVE_TIMEGM
 | |
| 
 | |
| static int
 | |
| is_leap(unsigned y)
 | |
| {
 | |
|   return (y % 4) == 0 && ((y % 100) != 0 || (y % 400) == 0);
 | |
| }
 | |
| 
 | |
| time_t
 | |
| timegm (struct tm *tm)
 | |
| {
 | |
|   static const int ndays[2][12] ={
 | |
|     {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
 | |
|     {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}};
 | |
|   time_t res = 0;
 | |
|   int i;
 | |
| 
 | |
|   for (i = 70; i < tm->tm_year; ++i)
 | |
|     res += is_leap(i) ? 366 : 365;
 | |
| 
 | |
|   for (i = 0; i < tm->tm_mon; ++i)
 | |
|     res += ndays[is_leap(tm->tm_year)][i];
 | |
|   res += tm->tm_mday - 1;
 | |
|   res *= 24;
 | |
|   res += tm->tm_hour;
 | |
|   res *= 60;
 | |
|   res += tm->tm_min;
 | |
|   res *= 60;
 | |
|   res += tm->tm_sec;
 | |
|   return res;
 | |
| }
 | |
| 
 | |
| #endif
 |