[gnote/stable-0.7] Pass const argument to localtime_r
- From: Aurimas Černius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote/stable-0.7] Pass const argument to localtime_r
- Date: Sun, 8 May 2011 13:29:50 +0000 (UTC)
commit 544c8bca7c63ca4bbeb05c95b9d09c25d3b1c5f0
Author: Aurimas Ä?ernius <aurisc4 gmail com>
Date: Sun May 8 16:14:20 2011 +0300
Pass const argument to localtime_r
Passing non-const breaks build on FreeBSD and OpenBSD.
Thanks Jasper Lievisse Adriaanse.
Fixes bug 649472.
src/sharp/datetime.cpp | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
---
diff --git a/src/sharp/datetime.cpp b/src/sharp/datetime.cpp
index 0d7aed4..506f8ba 100644
--- a/src/sharp/datetime.cpp
+++ b/src/sharp/datetime.cpp
@@ -70,28 +70,28 @@ namespace sharp {
int DateTime::day() const
{
struct tm result;
- localtime_r(&m_date.tv_sec, &result);
+ localtime_r(const_cast<const time_t *>(&m_date.tv_sec), &result);
return result.tm_mday;
}
int DateTime::month() const
{
struct tm result;
- localtime_r(&m_date.tv_sec, &result);
+ localtime_r(const_cast<const time_t *>(&m_date.tv_sec), &result);
return result.tm_mon + 1;
}
int DateTime::year() const
{
struct tm result;
- localtime_r(&m_date.tv_sec, &result);
+ localtime_r(const_cast<const time_t *>(&m_date.tv_sec), &result);
return result.tm_year + 1900;
}
int DateTime::day_of_year() const
{
struct tm result;
- localtime_r(&m_date.tv_sec, &result);
+ localtime_r(const_cast<const time_t *>(&m_date.tv_sec), &result);
return result.tm_yday;
}
@@ -110,14 +110,14 @@ namespace sharp {
std::string DateTime::to_string(const char * format) const
{
struct tm result;
- return _to_string(format, localtime_r(&m_date.tv_sec, &result));
+ return _to_string(format, localtime_r(const_cast<const time_t *>(&m_date.tv_sec), &result));
}
std::string DateTime::to_short_time_string() const
{
struct tm result;
- return _to_string("%R", localtime_r(&m_date.tv_sec, &result));
+ return _to_string("%R", localtime_r(const_cast<const time_t *>(&m_date.tv_sec), &result));
}
std::string DateTime::to_iso8601() const
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]