X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fsupport%2Flyxtime.cpp;h=5415ac4eeb034057234b363d3931d7d004ca40ba;hb=522f3517e1d7f61ed2bbcafe0632f50cb3e8ae2f;hp=9bdde9cb3af6696b68125cecd14ae4070b4012e3;hpb=aafd52f44167d5510be1ddcb974daa9dae486933;p=lyx.git diff --git a/src/support/lyxtime.cpp b/src/support/lyxtime.cpp index 9bdde9cb3a..5415ac4eeb 100644 --- a/src/support/lyxtime.cpp +++ b/src/support/lyxtime.cpp @@ -40,7 +40,19 @@ string const formatted_time(time_t t, string const & fmt) } -time_t from_ctime(string t) +docstring formatted_datetime(time_t t, string const & fmt) +{ + QString qres; + if (fmt.empty()) + qres = QLocale().toString(QDateTime::fromTime_t(t), + QLocale::ShortFormat); + else + qres = QLocale().toString(QDateTime::fromTime_t(t), toqstr(fmt)); + return qstring_to_ucs4(qres); +} + + +time_t from_asctime_utc(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 +69,7 @@ time_t from_ctime(string t) << "´ (invalid format)"); return static_cast(-1); } + loc_dt.setTimeSpec(Qt::UTC); return loc_dt.toTime_t(); }