Lines 104-114
Link Here
|
104 |
*/ |
104 |
*/ |
105 |
int str2Tm(const std::string& timeStr, struct tm* tm); |
105 |
int str2Tm(const std::string& timeStr, struct tm* tm); |
106 |
|
106 |
|
107 |
//! Convert a UTC time to a string "YYYY:MM:DD HH:MI:SS", "" on error |
107 |
//! Convert a localtime to a string "YYYY:MM:DD HH:MI:SS", "" on error |
108 |
std::string time2Str(time_t time); |
108 |
std::string time2Str(time_t time); |
109 |
|
109 |
|
110 |
//! Convert a tm structure to a string "YYYY:MM:DD HH:MI:SS", "" on error |
110 |
//! Convert a tm structure to a string "YYYY:MM:DD HH:MI:SS", "" on error |
111 |
std::string tm2Str(struct tm* tm); |
111 |
std::string tm2Str(const struct tm* tm); |
112 |
|
112 |
|
113 |
/*! |
113 |
/*! |
114 |
@brief Copy metadata from source to target according to Params::copyXyz |
114 |
@brief Copy metadata from source to target according to Params::copyXyz |
Lines 1565-1571
Link Here
|
1565 |
<< " " << _("years") << "\n"; |
1565 |
<< " " << _("years") << "\n"; |
1566 |
return 1; |
1566 |
return 1; |
1567 |
} |
1567 |
} |
1568 |
time_t time = timegm(&tm); |
1568 |
time_t time = mktime(&tm); |
1569 |
time += adjustment_ + dayAdjustment_ * 86400; |
1569 |
time += adjustment_ + dayAdjustment_ * 86400; |
1570 |
timeStr = time2Str(time); |
1570 |
timeStr = time2Str(time); |
1571 |
if (Params::instance().verbose_) { |
1571 |
if (Params::instance().verbose_) { |
Lines 1739-1745
Link Here
|
1739 |
int Timestamp::read(struct tm* tm) |
1739 |
int Timestamp::read(struct tm* tm) |
1740 |
{ |
1740 |
{ |
1741 |
int rc = 1; |
1741 |
int rc = 1; |
1742 |
time_t t = mktime(tm); |
1742 |
time_t t = mktime(tm); // interpret tm according to current timezone settings |
1743 |
if (t != (time_t)-1) { |
1743 |
if (t != (time_t)-1) { |
1744 |
rc = 0; |
1744 |
rc = 0; |
1745 |
actime_ = t; |
1745 |
actime_ = t; |
Lines 1783-1804
Link Here
|
1783 |
tm->tm_sec = tmp; |
1783 |
tm->tm_sec = tmp; |
1784 |
|
1784 |
|
1785 |
// Conversions to set remaining fields of the tm structure |
1785 |
// Conversions to set remaining fields of the tm structure |
1786 |
time_t time = timegm(tm); |
1786 |
if (mktime(tm) == (time_t)-1) return 11; |
1787 |
#ifdef EXV_HAVE_GMTIME_R |
1787 |
|
1788 |
if (time == (time_t)-1 || gmtime_r(&time, tm) == 0) return 11; |
|
|
1789 |
#else |
1790 |
if (time == (time_t)-1 || std::gmtime(&time) == 0) return 11; |
1791 |
#endif |
1792 |
return 0; |
1788 |
return 0; |
1793 |
} // str2Tm |
1789 |
} // str2Tm |
1794 |
|
1790 |
|
1795 |
std::string time2Str(time_t time) |
1791 |
std::string time2Str(time_t time) |
1796 |
{ |
1792 |
{ |
1797 |
struct tm* tm = gmtime(&time); |
1793 |
struct tm* tm = localtime(&time); |
1798 |
return tm2Str(tm); |
1794 |
return tm2Str(tm); |
1799 |
} // time2Str |
1795 |
} // time2Str |
1800 |
|
1796 |
|
1801 |
std::string tm2Str(struct tm* tm) |
1797 |
std::string tm2Str(const struct tm* tm) |
1802 |
{ |
1798 |
{ |
1803 |
if (0 == tm) return ""; |
1799 |
if (0 == tm) return ""; |
1804 |
|
1800 |
|