mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-26 23:36:59 -05:00
Fixed missing seconds in time format.
Added new basic class for date/time format. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5825 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
8a3973de81
commit
968f72f303
@ -42,7 +42,7 @@
|
||||
#include "channels/ShareKey.h"
|
||||
#include "notifyqt.h"
|
||||
#include "util/HandleRichText.h"
|
||||
#include "rshare.h"
|
||||
#include "util/DateTime.h"
|
||||
|
||||
#include <retroshare/rspeers.h>
|
||||
#include <retroshare/rsforums.h>
|
||||
@ -1522,17 +1522,14 @@ static QString buildReplyHeader(const ForumMsgInfo &msgInfo)
|
||||
link.createMessage(msgInfo.srcId, "");
|
||||
QString from = link.toHtml();
|
||||
|
||||
QDateTime qtime;
|
||||
qtime.setTime_t(msgInfo.ts);
|
||||
|
||||
QString header = QString("<span>-----%1-----").arg(QApplication::translate("ForumsDialog", "Original Message"));
|
||||
header += QString("<br><font size='3'><strong>%1: </strong>%2</font><br>").arg(QApplication::translate("ForumsDialog", "From"), from);
|
||||
|
||||
header += QString("<br><font size='3'><strong>%1: </strong>%2</font><br>").arg(QApplication::translate("ForumsDialog", "Sent"), Rshare::customLongDate(msgInfo.ts));
|
||||
header += QString("<br><font size='3'><strong>%1: </strong>%2</font><br>").arg(QApplication::translate("ForumsDialog", "Sent"), DateTime::formatLongDateTime(msgInfo.ts));
|
||||
header += QString("<font size='3'><strong>%1: </strong>%2</font></span><br>").arg(QApplication::translate("ForumsDialog", "Subject"), QString::fromStdWString(msgInfo.title));
|
||||
header += "<br>";
|
||||
|
||||
header += QApplication::translate("ForumsDialog", "On %1, %2 wrote:").arg(qtime.toString(Qt::DefaultLocaleShortDate), from);
|
||||
header += QApplication::translate("ForumsDialog", "On %1, %2 wrote:").arg(DateTime::formatDateTime(msgInfo.ts), from);
|
||||
|
||||
return header;
|
||||
}
|
||||
@ -1846,14 +1843,14 @@ void ForumsFillThread::run()
|
||||
else
|
||||
qtime.setTime_t(tit->ts);
|
||||
|
||||
text = qtime.toString(Qt::DefaultLocaleShortDate);
|
||||
text = DateTime::formatDateTime(qtime);
|
||||
sort = qtime.toString("yyyyMMdd_hhmmss");
|
||||
|
||||
if (useChildTS)
|
||||
{
|
||||
qtime.setTime_t(tit->ts);
|
||||
text += " / ";
|
||||
text += qtime.toString(Qt::DefaultLocaleShortDate);
|
||||
text += DateTime::formatDateTime(qtime);
|
||||
sort += "_" + qtime.toString("yyyyMMdd_hhmmss");
|
||||
}
|
||||
item->setText(COLUMN_THREAD_DATE, text);
|
||||
@ -1963,14 +1960,14 @@ void ForumsFillThread::run()
|
||||
else
|
||||
qtime.setTime_t(mit->ts);
|
||||
|
||||
text = qtime.toString(Qt::DefaultLocaleShortDate);
|
||||
text = DateTime::formatDateTime(qtime);
|
||||
sort = qtime.toString("yyyyMMdd_hhmmss");
|
||||
|
||||
if (useChildTS)
|
||||
{
|
||||
qtime.setTime_t(mit->ts);
|
||||
text += " / ";
|
||||
text += qtime.toString(Qt::DefaultLocaleShortDate);
|
||||
text += DateTime::formatDateTime(qtime);
|
||||
sort += "_" + qtime.toString("yyyyMMdd_hhmmss");
|
||||
}
|
||||
child->setText(COLUMN_THREAD_DATE, text);
|
||||
|
@ -50,6 +50,7 @@
|
||||
#include "settings/rsharesettings.h"
|
||||
#include "util/misc.h"
|
||||
#include "util/HandleRichText.h"
|
||||
#include "util/DateTime.h"
|
||||
#include "chat/CreateLobbyDialog.h"
|
||||
#include "FriendRecommendDialog.h"
|
||||
|
||||
@ -706,7 +707,7 @@ void FriendsDialog::setChatInfo(QString info, QColor color)
|
||||
ui.msgText->clear();
|
||||
nbLines = 1;
|
||||
}
|
||||
ui.msgText->append("<font color='grey'>" + QTime::currentTime().toString(Qt::DefaultLocaleShortDate) + "</font> - <font color='" + color.name() + "'><i>" + info + "</i></font>");
|
||||
ui.msgText->append("<font color='grey'>" + DateTime::formatTime(QTime::currentTime()) + "</font> - <font color='" + color.name() + "'><i>" + info + "</i></font>");
|
||||
}
|
||||
|
||||
void FriendsDialog::on_actionClear_Chat_History_triggered()
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "common/TagDefs.h"
|
||||
#include "common/PeerDefs.h"
|
||||
#include "common/RSItemDelegate.h"
|
||||
#include "util/DateTime.h"
|
||||
|
||||
#include <retroshare/rspeers.h>
|
||||
#include <retroshare/rsmsgs.h>
|
||||
@ -1051,14 +1052,11 @@ void MessagesDialog::insertMessages()
|
||||
//if the mail is on same date show only time.
|
||||
if (qdatetime.daysTo(QDateTime::currentDateTime()) == 0)
|
||||
{
|
||||
QTime qtime = qdatetime.time();
|
||||
QVariant varTime(qtime);
|
||||
item[COLUMN_DATE]->setData(varTime, Qt::DisplayRole);
|
||||
item[COLUMN_DATE]->setData(DateTime::formatTime(qdatetime.time()), Qt::DisplayRole);
|
||||
}
|
||||
else
|
||||
{
|
||||
QVariant varDateTime(qdatetime);
|
||||
item[COLUMN_DATE]->setData(varDateTime, Qt::DisplayRole);
|
||||
item[COLUMN_DATE]->setData(DateTime::formatDateTime(qdatetime), Qt::DisplayRole);
|
||||
}
|
||||
// for sorting
|
||||
item[COLUMN_DATE]->setData(qdatetime, ROLE_SORT);
|
||||
|
@ -19,7 +19,7 @@
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
#include "ChannelDetails.h"
|
||||
#include "rshare.h"
|
||||
#include "util/DateTime.h"
|
||||
|
||||
#include <retroshare/rsiface.h>
|
||||
#include <retroshare/rspeers.h>
|
||||
@ -95,7 +95,7 @@ void ChannelDetails::loadChannel()
|
||||
|
||||
// Set Last Channel Post Date
|
||||
if (ci.lastPost) {
|
||||
ui.postline->setText(Rshare::customLongDate(ci.lastPost));
|
||||
ui.postline->setText(DateTime::formatLongDateTime(ci.lastPost));
|
||||
}
|
||||
|
||||
// Set Channel ID
|
||||
|
@ -105,6 +105,7 @@
|
||||
#include "ChatStyle.h"
|
||||
#include "gui/settings/rsharesettings.h"
|
||||
#include "gui/notifyqt.h"
|
||||
#include "util/DateTime.h"
|
||||
|
||||
#include <retroshare/rsinit.h>
|
||||
|
||||
@ -323,8 +324,8 @@ QString ChatStyle::formatMessage(enumFormatMessage type, const QString &name, co
|
||||
#endif
|
||||
|
||||
QString formatMsg = style.replace("%name%", name)
|
||||
.replace("%date%", timestamp.date().toString(Qt::DefaultLocaleShortDate))
|
||||
.replace("%time%", timestamp.time().toString(Qt::DefaultLocaleShortDate))
|
||||
.replace("%date%", DateTime::formatDate(timestamp.date()))
|
||||
.replace("%time%", DateTime::formatTime(timestamp.time()))
|
||||
#ifdef COLORED_NICKNAMES
|
||||
.replace("%color%", color.name())
|
||||
#endif
|
||||
|
@ -40,7 +40,7 @@
|
||||
#include "gui/notifyqt.h"
|
||||
#include "gui/common/AvatarDefs.h"
|
||||
#include "gui/MainWindow.h"
|
||||
#include "rshare.h"
|
||||
#include "util/DateTime.h"
|
||||
|
||||
static QMap<std::string, ConfCertDialog*> instances;
|
||||
|
||||
@ -165,7 +165,7 @@ void ConfCertDialog::load()
|
||||
|
||||
ui.loc->setText(QString::fromUtf8(detail.location.c_str()));
|
||||
// Dont Show a timestamp in RS calculate the day
|
||||
ui.lastcontact->setText(Rshare::customLongDate(detail.lastConnect));
|
||||
ui.lastcontact->setText(DateTime::formatLongDateTime(detail.lastConnect));
|
||||
|
||||
/* set retroshare version */
|
||||
std::map<std::string, std::string>::iterator vit;
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "util/misc.h"
|
||||
#include "gui/RetroShareLink.h"
|
||||
#include "util/HandleRichText.h"
|
||||
#include "util/DateTime.h"
|
||||
|
||||
#include <retroshare/rschannels.h>
|
||||
|
||||
@ -188,7 +189,7 @@ void ChanMsgItem::updateItemStatic()
|
||||
msgLabel->setText(RsHtml().formatText(NULL, QString::fromStdWString(cmi.msg), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS));
|
||||
msgFrame->setVisible(!cmi.msg.empty());
|
||||
|
||||
datetimelabel->setText(Rshare::customLongDate(cmi.ts));
|
||||
datetimelabel->setText(DateTime::formatLongDateTime(cmi.ts));
|
||||
|
||||
filelabel->setText(QString("(%1 %2) %3").arg(cmi.count).arg(tr("Files")).arg(misc::friendlyUnit(cmi.size)));
|
||||
|
||||
|
@ -27,9 +27,9 @@
|
||||
#include "retroshare-gui/RsAutoUpdatePage.h"
|
||||
#include "gui/msgs/MessageComposer.h"
|
||||
#include "util/HandleRichText.h"
|
||||
#include "util/DateTime.h"
|
||||
#include "gui/common/AvatarDefs.h"
|
||||
#include "gui/settings/rsharesettings.h"
|
||||
#include "rshare.h"
|
||||
|
||||
#include "gui/notifyqt.h"
|
||||
|
||||
@ -138,7 +138,7 @@ void ChatMsgItem::insertChat(const std::string &message)
|
||||
std::cerr << "ChatMsgItem::insertChat(): " << msg << std::endl;
|
||||
#endif
|
||||
|
||||
timestampLabel->setText(Rshare::customLongDate(QDateTime::currentDateTime()));
|
||||
timestampLabel->setText(DateTime::formatLongDateTime(QDateTime::currentDateTime()));
|
||||
|
||||
QString formatMsg = QString::fromUtf8(message.c_str());
|
||||
|
||||
|
@ -32,10 +32,10 @@
|
||||
|
||||
#include "gui/forums/CreateForumMsg.h"
|
||||
#include "util/HandleRichText.h"
|
||||
#include "util/DateTime.h"
|
||||
#include "gui/common/AvatarDefs.h"
|
||||
#include "gui/notifyqt.h"
|
||||
#include "gui/ForumsDialog.h"
|
||||
#include "rshare.h"
|
||||
//#include "gui/settings/rsharesettings.h"
|
||||
|
||||
/****
|
||||
@ -161,7 +161,7 @@ void ForumMsgItem::updateItemStatic()
|
||||
prevSubLabel->setText(link.toHtml());
|
||||
prevMsgLabel->setText(RsHtml().formatText(NULL, ForumsDialog::messageFromInfo(msg), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS));
|
||||
|
||||
timestamplabel->setText(Rshare::customLongDate(msg.ts));
|
||||
timestamplabel->setText(DateTime::formatLongDateTime(msg.ts));
|
||||
|
||||
nextFrame->hide();
|
||||
}
|
||||
@ -183,7 +183,7 @@ void ForumMsgItem::updateItemStatic()
|
||||
nextSubLabel->setText(link.toHtml());
|
||||
nextMsgLabel->setText(RsHtml().formatText(NULL, ForumsDialog::messageFromInfo(msg), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS));
|
||||
|
||||
timestamplabel->setText(Rshare::customLongDate(msg.ts));
|
||||
timestamplabel->setText(DateTime::formatLongDateTime(msg.ts));
|
||||
|
||||
prevSHLabel->setText(tr("In Reply to") + ": ");
|
||||
|
||||
|
@ -27,12 +27,13 @@
|
||||
#include "SubFileItem.h"
|
||||
#include "gui/msgs/MessageComposer.h"
|
||||
#include "util/HandleRichText.h"
|
||||
#include "util/DateTime.h"
|
||||
#include "gui/common/AvatarDefs.h"
|
||||
#include "gui/notifyqt.h"
|
||||
|
||||
#include <retroshare/rsmsgs.h>
|
||||
#include <retroshare/rspeers.h>
|
||||
#include "rshare.h"
|
||||
|
||||
/****
|
||||
* #define DEBUG_ITEM 1
|
||||
****/
|
||||
@ -92,9 +93,7 @@ void MsgItem::updateItemStatic()
|
||||
srcName = QString::fromUtf8(rsPeers->getPeerName(mi.srcId).c_str());
|
||||
}
|
||||
|
||||
{
|
||||
timestampLabel->setText(Rshare::customLongDate(mi.ts));
|
||||
}
|
||||
timestampLabel->setText(DateTime::formatLongDateTime(mi.ts));
|
||||
|
||||
if (!mIsHome)
|
||||
{
|
||||
|
@ -28,7 +28,7 @@
|
||||
#include "gui/msgs/MessageComposer.h"
|
||||
#include "gui/common/StatusDefs.h"
|
||||
#include "gui/common/AvatarDefs.h"
|
||||
#include "rshare.h"
|
||||
#include "util/DateTime.h"
|
||||
|
||||
#include "gui/notifyqt.h"
|
||||
|
||||
@ -118,7 +118,7 @@ void PeerItem::updateItemStatic()
|
||||
{
|
||||
/* set peer name */
|
||||
peerNameLabel->setText(QString::fromUtf8(details.name.c_str()));
|
||||
lastLabel-> setText(Rshare::customLongDate(details.lastConnect));
|
||||
lastLabel-> setText(DateTime::formatLongDateTime(details.lastConnect));
|
||||
|
||||
/* expanded Info */
|
||||
nameLabel->setText(QString::fromUtf8(details.name.c_str()));
|
||||
|
@ -31,12 +31,12 @@
|
||||
#include "gui/connect/ConfCertDialog.h"
|
||||
#include "gui/connect/ConnectFriendWizard.h"
|
||||
#include "gui/common/AvatarDefs.h"
|
||||
#include "util/DateTime.h"
|
||||
|
||||
#include "gui/notifyqt.h"
|
||||
|
||||
#include <retroshare/rsmsgs.h>
|
||||
#include <retroshare/rspeers.h>
|
||||
#include "rshare.h"
|
||||
|
||||
/*****
|
||||
* #define DEBUG_ITEM 1
|
||||
@ -145,7 +145,7 @@ void SecurityItem::updateItemStatic()
|
||||
titleLabel->setText(title);
|
||||
|
||||
QDateTime currentTime = QDateTime::currentDateTime();
|
||||
timeLabel->setText(Rshare::customLongDate(currentTime.toTime_t()));
|
||||
timeLabel->setText(DateTime::formatLongDateTime(currentTime.toTime_t()));
|
||||
|
||||
if (mIsHome)
|
||||
{
|
||||
|
@ -19,7 +19,7 @@
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
#include "ForumDetails.h"
|
||||
#include "rshare.h"
|
||||
#include "util/DateTime.h"
|
||||
|
||||
#include <retroshare/rsiface.h>
|
||||
#include <retroshare/rspeers.h>
|
||||
@ -90,7 +90,7 @@ void ForumDetails::loadDialog()
|
||||
|
||||
// Set Last Post Date
|
||||
if (fi.lastPost) {
|
||||
ui.postline->setText(Rshare::customLongDate(fi.lastPost));
|
||||
ui.postline->setText(DateTime::formatLongDateTime(fi.lastPost));
|
||||
}
|
||||
|
||||
// Set Forum ID
|
||||
|
@ -33,10 +33,10 @@
|
||||
#include <QItemDelegate>
|
||||
#include <QDateTime>
|
||||
#include <QFileInfo>
|
||||
#include <QTextStream>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "rshare.h"
|
||||
#include "MessageComposer.h"
|
||||
|
||||
#include <retroshare/rsiface.h>
|
||||
@ -55,6 +55,7 @@
|
||||
#include "gui/common/Emoticons.h"
|
||||
#include "textformat.h"
|
||||
#include "util/misc.h"
|
||||
#include "util/DateTime.h"
|
||||
#include "TagsMenu.h"
|
||||
#include "gui/common/TagDefs.h"
|
||||
#include "gui/connect/ConfCertDialog.h"
|
||||
@ -947,9 +948,6 @@ QString MessageComposer::buildReplyHeader(const MessageInfo &msgInfo)
|
||||
}
|
||||
}
|
||||
|
||||
QDateTime qtime;
|
||||
qtime.setTime_t(msgInfo.ts);
|
||||
|
||||
QString header = QString("<span>-----%1-----").arg(tr("Original Message"));
|
||||
header += QString("<br><font size='3'><strong>%1: </strong>%2</font><br>").arg(tr("From"), from);
|
||||
header += QString("<font size='3'><strong>%1: </strong>%2</font><br>").arg(tr("To"), to);
|
||||
@ -958,11 +956,11 @@ QString MessageComposer::buildReplyHeader(const MessageInfo &msgInfo)
|
||||
header += QString("<font size='3'><strong>%1: </strong>%2</font><br>").arg(tr("Cc"), cc);
|
||||
}
|
||||
|
||||
header += QString("<br><font size='3'><strong>%1: </strong>%2</font><br>").arg(tr("Sent"), Rshare::customLongDate(qtime));
|
||||
header += QString("<br><font size='3'><strong>%1: </strong>%2</font><br>").arg(tr("Sent"), DateTime::formatLongDateTime(msgInfo.ts));
|
||||
header += QString("<font size='3'><strong>%1: </strong>%2</font></span><br>").arg(tr("Subject"), QString::fromStdWString(msgInfo.title));
|
||||
header += "<br>";
|
||||
|
||||
header += tr("On %1, %2 wrote:").arg(qtime.toString(Qt::DefaultLocaleShortDate), from);
|
||||
header += tr("On %1, %2 wrote:").arg(DateTime::formatDateTime(msgInfo.ts), from);
|
||||
|
||||
return header;
|
||||
}
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include "util/misc.h"
|
||||
#include "util/printpreview.h"
|
||||
#include "util/HandleRichText.h"
|
||||
#include "util/DateTime.h"
|
||||
|
||||
#include <retroshare/rspeers.h>
|
||||
#include <retroshare/rsfiles.h>
|
||||
@ -533,11 +534,7 @@ void MessageWidget::fill(const std::string &msgId)
|
||||
ui.bccText->clear();
|
||||
}
|
||||
|
||||
{
|
||||
QDateTime qtime;
|
||||
qtime.setTime_t(msgInfo.ts);
|
||||
ui.dateText->setText(qtime.toString(Qt::DefaultLocaleShortDate));
|
||||
}
|
||||
ui.dateText->setText(DateTime::formatDateTime(msgInfo.ts));
|
||||
|
||||
std::string ownId = rsPeers->getOwnId();
|
||||
|
||||
|
@ -271,6 +271,7 @@ HEADERS += rshare.h \
|
||||
gui/im_history/IMHistoryItemPainter.h \
|
||||
lang/languagesupport.h \
|
||||
util/stringutil.h \
|
||||
util/DateTime.h \
|
||||
util/win32.h \
|
||||
util/RetroStyleLabel.h \
|
||||
util/dllexport.h \
|
||||
@ -571,6 +572,7 @@ SOURCES += main.cpp \
|
||||
gui/xprogressbar.cpp \
|
||||
lang/languagesupport.cpp \
|
||||
util/stringutil.cpp \
|
||||
util/DateTime.cpp \
|
||||
util/win32.cpp \
|
||||
util/RetroStyleLabel.cpp \
|
||||
util/WidgetBackgroundImage.cpp \
|
||||
|
@ -57,8 +57,7 @@ QMap<QString, QString> Rshare::_args; /**< List of command-line arguments. */
|
||||
QString Rshare::_style; /**< The current GUI style. */
|
||||
QString Rshare::_language; /**< The current language. */
|
||||
QString Rshare::_stylesheet; /**< The current GUI stylesheet. */
|
||||
QString Rshare::_datetimeformat; /**< The format of dates in feed items etc. */
|
||||
QLocale Rshare::_locale; /**< The locale. */
|
||||
QString Rshare::_dateformat; /**< The format of dates in feed items etc. */
|
||||
Log Rshare::_log;
|
||||
bool Rshare::useConfigDir;
|
||||
QString Rshare::configDir;
|
||||
@ -356,31 +355,21 @@ Rshare::setLocale(QString languageCode)
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/** return custom formatted date */
|
||||
QString Rshare::customLongDate(uint fromTime)
|
||||
{
|
||||
return customLongDate(QDateTime::fromTime_t(fromTime));
|
||||
}
|
||||
|
||||
QString Rshare::customLongDate(const QDateTime &fromTime)
|
||||
{
|
||||
if (_datetimeformat.isEmpty()) {
|
||||
return fromTime.toString(Qt::ISODate);
|
||||
} else {
|
||||
return _locale.toString(fromTime, _datetimeformat);
|
||||
}
|
||||
}
|
||||
|
||||
/** customize date format for feeds etc. */
|
||||
void Rshare::customizeDateFormat()
|
||||
{
|
||||
_locale = QLocale(); // set to default locale
|
||||
QLocale locale = QLocale(); // set to default locale
|
||||
/* get long date format without weekday */
|
||||
QString dateformat = _locale.dateFormat(QLocale::LongFormat);
|
||||
dateformat.replace(QRegExp("^dddd,*[^ ]* *('[^']+' )*"), "");
|
||||
dateformat.replace(QRegExp(",* *dddd"), "");
|
||||
dateformat = dateformat.trimmed();
|
||||
_datetimeformat = dateformat + " " + _locale.timeFormat(QLocale::ShortFormat);
|
||||
_dateformat = locale.dateFormat(QLocale::LongFormat);
|
||||
_dateformat.replace(QRegExp("^dddd,*[^ ]* *('[^']+' )*"), "");
|
||||
_dateformat.replace(QRegExp(",* *dddd"), "");
|
||||
_dateformat = _dateformat.trimmed();
|
||||
}
|
||||
|
||||
/** Get custom date format (defaultlongformat) */
|
||||
QString Rshare::customDateFormat()
|
||||
{
|
||||
return _dateformat;
|
||||
}
|
||||
|
||||
/** Sets the GUI style RetroShare will use. If one was specified on the
|
||||
|
@ -75,9 +75,9 @@ public:
|
||||
static bool setLanguage(QString languageCode = QString());
|
||||
/** Sets the current locale. */
|
||||
static bool setLocale(QString languageCode = QString());
|
||||
/** Returns custom formatted date */
|
||||
static QString customLongDate(uint fromTime);
|
||||
static QString customLongDate(const QDateTime &fromTime);
|
||||
/** Get custom date format (defaultlongformat) */
|
||||
static QString customDateFormat();
|
||||
|
||||
/** Sets the current GUI style. */
|
||||
static bool setStyle(QString styleKey = QString());
|
||||
/** Sets the current GUI stylesheet. */
|
||||
@ -169,8 +169,7 @@ private:
|
||||
static QString _style; /**< The current GUI style. */
|
||||
static QString _stylesheet; /**< The current GUI stylesheet. */
|
||||
static QString _language; /**< The current language. */
|
||||
static QString _datetimeformat; /**< The format for dates in feed items etc. */
|
||||
static QLocale _locale; /**< The locale (object). */
|
||||
static QString _dateformat; /**< The format for dates in feed items etc. */
|
||||
static Log _log; /**< Logs debugging messages to file or stdout. */
|
||||
|
||||
static bool useConfigDir;
|
||||
|
81
retroshare-gui/src/util/DateTime.cpp
Normal file
81
retroshare-gui/src/util/DateTime.cpp
Normal file
@ -0,0 +1,81 @@
|
||||
/****************************************************************
|
||||
* This file is distributed under the following license:
|
||||
*
|
||||
* Copyright (c) 2012, RetroShare Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#include <QDateTime>
|
||||
|
||||
#include "DateTime.h"
|
||||
#include "rshare.h"
|
||||
|
||||
QString DateTime::formatLongDate(time_t dateValue)
|
||||
{
|
||||
return formatLongDate(QDateTime::fromTime_t(dateValue).date());
|
||||
}
|
||||
|
||||
QString DateTime::formatLongDate(const QDate &dateValue)
|
||||
{
|
||||
QString customDateFormat = Rshare::customDateFormat();
|
||||
|
||||
if (customDateFormat.isEmpty()) {
|
||||
return dateValue.toString(Qt::ISODate);
|
||||
} else {
|
||||
return QLocale().toString(dateValue, customDateFormat);
|
||||
}
|
||||
}
|
||||
|
||||
QString DateTime::formatLongDateTime(time_t datetimeValue)
|
||||
{
|
||||
return formatLongDateTime(QDateTime::fromTime_t(datetimeValue));
|
||||
}
|
||||
|
||||
QString DateTime::formatLongDateTime(const QDateTime &datetimeValue)
|
||||
{
|
||||
return formatLongDate(datetimeValue.date()) + " " + formatTime(datetimeValue.time());
|
||||
}
|
||||
|
||||
QString DateTime::formatDateTime(time_t datetimeValue)
|
||||
{
|
||||
return formatDateTime(QDateTime::fromTime_t(datetimeValue));
|
||||
}
|
||||
|
||||
QString DateTime::formatDateTime(const QDateTime &datetimeValue)
|
||||
{
|
||||
return formatDate(datetimeValue.date()) + " " + formatTime(datetimeValue.time());
|
||||
}
|
||||
|
||||
QString DateTime::formatDate(time_t dateValue)
|
||||
{
|
||||
return formatDate(QDateTime::fromTime_t(dateValue).date());
|
||||
}
|
||||
|
||||
QString DateTime::formatDate(const QDate &dateValue)
|
||||
{
|
||||
return dateValue.toString(Qt::SystemLocaleShortDate);
|
||||
}
|
||||
|
||||
QString DateTime::formatTime(time_t timeValue)
|
||||
{
|
||||
return formatTime(QDateTime::fromTime_t(timeValue).time());
|
||||
}
|
||||
|
||||
QString DateTime::formatTime(const QTime &timeValue)
|
||||
{
|
||||
return timeValue.toString(Qt::SystemLocaleShortDate);
|
||||
}
|
55
retroshare-gui/src/util/DateTime.h
Normal file
55
retroshare-gui/src/util/DateTime.h
Normal file
@ -0,0 +1,55 @@
|
||||
/****************************************************************
|
||||
* This file is distributed under the following license:
|
||||
*
|
||||
* Copyright (c) 20120, RetroShare Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#ifndef _DATETIME_H
|
||||
#define _DATETIME_H
|
||||
|
||||
#include <QString>
|
||||
|
||||
class QDateTime;
|
||||
class QDate;
|
||||
class QTime;
|
||||
|
||||
class DateTime
|
||||
{
|
||||
public:
|
||||
/* format long date and time e.g. "September 30, 2012" */
|
||||
static QString formatLongDate(time_t dateValue);
|
||||
static QString formatLongDate(const QDate &dateValue);
|
||||
|
||||
/* format long date and time e.g. "September 30, 2012 01:05 PM" */
|
||||
static QString formatLongDateTime(time_t datetimeValue);
|
||||
static QString formatLongDateTime(const QDateTime &datetimeValue);
|
||||
|
||||
/* format date e.g. "9/30/12", "30.09.12" */
|
||||
static QString formatDate(time_t dateValue);
|
||||
static QString formatDate(const QDate &dateValue);
|
||||
|
||||
/* format time e.g. "13:05:12" */
|
||||
static QString formatTime(time_t timeValue);
|
||||
static QString formatTime(const QTime &timeValue);
|
||||
|
||||
/* format date and time (see formatDate & formatTime) */
|
||||
static QString formatDateTime(time_t datetimeValue);
|
||||
static QString formatDateTime(const QDateTime &datetimeValue);
|
||||
};
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user