< prev index next >

hotspot/src/share/vm/runtime/os.cpp

Print this page




 107   }
 108   if (buffer_length < needed_buffer) {
 109     assert(false, "buffer_length too small");
 110     return NULL;
 111   }
 112   // Get the current time
 113   jlong milliseconds_since_19700101 = javaTimeMillis();
 114   const int milliseconds_per_microsecond = 1000;
 115   const time_t seconds_since_19700101 =
 116     milliseconds_since_19700101 / milliseconds_per_microsecond;
 117   const int milliseconds_after_second =
 118     milliseconds_since_19700101 % milliseconds_per_microsecond;
 119   // Convert the time value to a tm and timezone variable
 120   struct tm time_struct;
 121   if (localtime_pd(&seconds_since_19700101, &time_struct) == NULL) {
 122     assert(false, "Failed localtime_pd");
 123     return NULL;
 124   }
 125 #if defined(_ALLBSD_SOURCE)
 126   const time_t zone = (time_t) time_struct.tm_gmtoff;


 127 #else
 128   const time_t zone = timezone;
 129 #endif
 130 
 131   // If daylight savings time is in effect,
 132   // we are 1 hour East of our time zone
 133   const time_t seconds_per_minute = 60;
 134   const time_t minutes_per_hour = 60;
 135   const time_t seconds_per_hour = seconds_per_minute * minutes_per_hour;
 136   time_t UTC_to_local = zone;
 137   if (time_struct.tm_isdst > 0) {
 138     UTC_to_local = UTC_to_local - seconds_per_hour;
 139   }
 140   // Compute the time zone offset.
 141   //    localtime_pd() sets timezone to the difference (in seconds)
 142   //    between UTC and and local time.
 143   //    ISO 8601 says we need the difference between local time and UTC,
 144   //    we change the sign of the localtime_pd() result.
 145   const time_t local_to_UTC = -(UTC_to_local);
 146   // Then we have to figure out if if we are ahead (+) or behind (-) UTC.




 107   }
 108   if (buffer_length < needed_buffer) {
 109     assert(false, "buffer_length too small");
 110     return NULL;
 111   }
 112   // Get the current time
 113   jlong milliseconds_since_19700101 = javaTimeMillis();
 114   const int milliseconds_per_microsecond = 1000;
 115   const time_t seconds_since_19700101 =
 116     milliseconds_since_19700101 / milliseconds_per_microsecond;
 117   const int milliseconds_after_second =
 118     milliseconds_since_19700101 % milliseconds_per_microsecond;
 119   // Convert the time value to a tm and timezone variable
 120   struct tm time_struct;
 121   if (localtime_pd(&seconds_since_19700101, &time_struct) == NULL) {
 122     assert(false, "Failed localtime_pd");
 123     return NULL;
 124   }
 125 #if defined(_ALLBSD_SOURCE)
 126   const time_t zone = (time_t) time_struct.tm_gmtoff;
 127 #elif defined(_WIN32) && _MSC_VER > 1800
 128   const time_t zone = _timezone;
 129 #else
 130   const time_t zone = timezone;
 131 #endif
 132 
 133   // If daylight savings time is in effect,
 134   // we are 1 hour East of our time zone
 135   const time_t seconds_per_minute = 60;
 136   const time_t minutes_per_hour = 60;
 137   const time_t seconds_per_hour = seconds_per_minute * minutes_per_hour;
 138   time_t UTC_to_local = zone;
 139   if (time_struct.tm_isdst > 0) {
 140     UTC_to_local = UTC_to_local - seconds_per_hour;
 141   }
 142   // Compute the time zone offset.
 143   //    localtime_pd() sets timezone to the difference (in seconds)
 144   //    between UTC and and local time.
 145   //    ISO 8601 says we need the difference between local time and UTC,
 146   //    we change the sign of the localtime_pd() result.
 147   const time_t local_to_UTC = -(UTC_to_local);
 148   // Then we have to figure out if if we are ahead (+) or behind (-) UTC.


< prev index next >