Logo Search packages:      
Sourcecode: pbs-drmaa version File versions

time_t fsd_datetime_mktime ( const fsd_datetime_t dt )

Makes UTC datetime from (possibly not absolute) fsd_datetime_t.

Definition at line 158 of file datetime.c.

References fsd_datetime_s::day, fsd_datetime_s::hour, fsd_datetime_s::minute, fsd_datetime_s::month, fsd_datetime_s::second, fsd_datetime_s::tz_delta, and fsd_datetime_s::year.

Referenced by fsd_datetime_after().

{
      const unsigned month_days[12]
            = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 };
      unsigned long year, month;
      unsigned long years, days;
      time_t result;
#ifdef DEBUGGING
      char dbg[ 128 ];
      fsd_datetime_dump( dt, dbg, sizeof(dbg) );
      fsd_log_enter(( "(dt={%s})", dbg ));
#endif
      year = dt->year;
      month = dt->month;
      while( month < 1 )
       { year--;  month += 12; }
      while( month > 12 )
       { year++;  month -= 12; }
      years = year - 1970;
      days = 365*years + (years+1)/4;
      days += month_days[ month-1 ];
      if( month > 2  &&  (year&3) == 0 )
            days ++;
      days += dt->day - 1;
      result = ( ( days*24 + dt->hour )*60 + dt->minute )*60
            + dt->second - dt->tz_delta;
#ifdef DEBUGGING
       {
            struct tm utc_tm;
            gmtime_r( &result, &utc_tm );
            fsd_log_trace(( "years=%ld, days=%ld", years, days ));
            fsd_log_return(( " =%ld (%04d-%02d-%02d %02d:%02d:%02d+00:00)",
                              result,
                              1900+utc_tm.tm_year, 1+utc_tm.tm_mon, utc_tm.tm_mday,
                              utc_tm.tm_hour, utc_tm.tm_min, utc_tm.tm_sec
                              ));
       }
#endif
      return result;
}

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index