Make change tracking in export to latex be independent of timezone

This commit is contained in:
Kornel Benko 2013-01-07 15:46:47 +01:00
parent df57b7050b
commit e04523f77b
5 changed files with 9 additions and 10 deletions

View File

@ -400,7 +400,7 @@ int Changes::latexMarkChange(otexstream & os, BufferParams const & bparams,
}
docstring chgTime;
chgTime += ctime(&change.changetime);
chgTime += asctime(gmtime(&change.changetime));
// remove trailing '\n'
chgTime.erase(chgTime.end() - 1);

View File

@ -40,7 +40,7 @@ string const formatted_time(time_t t, string const & fmt)
}
time_t from_ctime(string t)
time_t from_gmtime(string t)
{
// Example for the format: "Sun Nov 6 10:39:39 2011\n"
// Generously remove trailing '\n' (and other whitespace if needed)
@ -57,6 +57,7 @@ time_t from_ctime(string t)
<< "´ (invalid format)");
return static_cast<time_t>(-1);
}
loc_dt.setTimeSpec(Qt::UTC);
return loc_dt.toTime_t();
}

View File

@ -34,7 +34,7 @@ std::string const formatted_time(time_t t, std::string const & fmt);
* time zone and daylight saving time are the same as when \p t was created
* by ctime().
*/
time_t from_ctime(std::string t);
time_t from_gmtime(std::string t);
} // namespace support
} // namespace lyx

View File

@ -107,9 +107,9 @@ An environment
\end{quote}
We also support change tracking:
\lyxadded{Hans Wurst}{Sun Nov 6 10:39:39 2011}{Added text}
\lyxadded{Hans Wurst}{Sun Nov 6 09:39:39 2011}{Added text}
some parts remain
\lyxdeleted{Hans Wurst}{Sun Nov 6 10:39:55 2011}{This was the original text}
\lyxdeleted{Hans Wurst}{Sun Nov 6 09:39:55 2011}{This was the original text}
some parts remain
\section*{A starred section for floats}

View File

@ -3204,11 +3204,9 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
string localtime = p.getArg('{', '}');
preamble.registerAuthor(name);
Author const & author = preamble.getAuthor(name);
// from_ctime() will fail if LyX decides to output the
// time in the text language. It might also use a wrong
// time zone (if the original LyX document was exported
// with a different time zone).
time_t ptime = from_ctime(localtime);
// from_gmtime() will fail if LyX decides to output the
// time in the text language.
time_t ptime = from_gmtime(localtime);
if (ptime == static_cast<time_t>(-1)) {
cerr << "Warning: Could not parse time `" << localtime
<< "´ for change tracking, using current time instead.\n";