mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 13:40:05 +00:00
Date/time formatting fixes
This commit is contained in:
parent
6c482b4ccf
commit
d9bcb7f086
2 changed files with 12 additions and 7 deletions
|
|
@ -1142,8 +1142,8 @@ void MainWindowImpl::ConnectOtherSignals()
|
|||
this,
|
||||
[this]()
|
||||
{
|
||||
timeLabel_->setText(QString("%1 UTC").arg(QString::fromStdString(
|
||||
util::TimeString(std::chrono::system_clock::now()))));
|
||||
timeLabel_->setText(QString::fromStdString(
|
||||
util::TimeString(std::chrono::system_clock::now())));
|
||||
timeLabel_->setVisible(true);
|
||||
});
|
||||
clockTimer_.start(1000);
|
||||
|
|
|
|||
|
|
@ -55,7 +55,12 @@ std::string TimeString(std::chrono::system_clock::time_point time,
|
|||
{
|
||||
using namespace std::chrono;
|
||||
|
||||
#if !defined(_MSC_VER)
|
||||
#if defined(_MSC_VER)
|
||||
# define FORMAT_STRING_24_HOUR "{:%Y-%m-%d %H:%M:%S %Z}"
|
||||
# define FORMAT_STRING_12_HOUR "{:%Y-%m-%d %I:%M:%S %p %Z}"
|
||||
#else
|
||||
# define FORMAT_STRING_24_HOUR "%Y-%m-%d %H:%M:%S %Z"
|
||||
# define FORMAT_STRING_12_HOUR "%Y-%m-%d %I:%M:%S %p %Z"
|
||||
using namespace date;
|
||||
#endif
|
||||
|
||||
|
|
@ -70,22 +75,22 @@ std::string TimeString(std::chrono::system_clock::time_point time,
|
|||
|
||||
if (clockFormat == ClockFormat::_24Hour)
|
||||
{
|
||||
os << format("{:%Y-%m-%d %H:%M:%S %Z}", zt);
|
||||
os << format(FORMAT_STRING_24_HOUR, zt);
|
||||
}
|
||||
else
|
||||
{
|
||||
os << format("{:%Y-%m-%d %I:%M:%S %p %Z}", zt);
|
||||
os << format(FORMAT_STRING_12_HOUR, zt);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (clockFormat == ClockFormat::_24Hour)
|
||||
{
|
||||
os << format("{:%Y-%m-%d %H:%M:%S %Z}", timeInSeconds);
|
||||
os << format(FORMAT_STRING_24_HOUR, timeInSeconds);
|
||||
}
|
||||
else
|
||||
{
|
||||
os << format("{:%Y-%m-%d %I:%M:%S %p %Z}", timeInSeconds);
|
||||
os << format(FORMAT_STRING_12_HOUR, timeInSeconds);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue