| 242 | } |
| 243 | |
| 244 | Date Date::UtcToday() { |
| 245 | struct tm* tm; |
| 246 | struct tm tms; |
| 247 | time_t t = time(NULL); |
| 248 | #if _POSIX_C_SOURCE >= 1 || _XOPEN_SOURCE || _BSD_SOURCE || _SVID_SOURCE || _POSIX_SOURCE |
| 249 | tm = gmtime_r(&t, &tms); |
| 250 | #else |
| 251 | tm = gmtime(&t); // NOLINT(runtime/threadsafe_fn) |
| 252 | #endif |
| 253 | return Date(tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday); |
| 254 | } |
| 255 | |
| 256 | bool Date::IsLeapYear(int year) { |
| 257 | return (year % 4 == 0 && year % 100 != 0) || year % 400 == 0; |