##// END OF EJS Templates
Introduced opaque library from Kyle Markley and improved DateTimeRange...
Introduced opaque library from Kyle Markley and improved DateTimeRange class Opaque library allow safer manipulation of numeric values and gives tem a meaning. This should help to prevent stupid mistakes. A first usage in SciQLop is Seconds which are double but have a specific meaning, a DateTimeRange can only be multiplied by a double (-> zoom) but only seconds can be added to it (-> pan). Even a zoom could be an opaque type in the future: Range/Range->Zoom, Range*Zoom->Range, Zoom*Range->Error. DateTimeRange class has now many arithmetic operators implemented this will allow to implement zoom/pan operations in only one place and test them. Signed-off-by: Alexis Jeandet <alexis.jeandet@member.fsf.org>

File last commit:

r0:86b06c4cec3c
r4:96a6baa9f92b
Show More
Version.cpp
78 lines | 3.0 KiB | text/x-c | CppLexer
#include "Version.h"
/***************************************************
* DON'T CHANGE THIS FILE. AUTOGENERATED BY CMAKE. *
***************************************************/
#include <QtCore/QDateTime>
#include <QtCore/QStringList>
namespace sciqlop {
const char *Version::VERSION_SUFFIX = "";
/**
* From the C99 standard:
* __DATE__: The date of translation of the preprocessing translation unit:
* a character string literal of the form "Mmm dd yyyy", where the names of
* the months are the same as those generated by the asctime function, and
* the first character of dd is a space character if the value is less than
* 10. If the date of translation is not available, an
* implementation-defined valid date shall be supplied.
*/
const char *Version::BUILD_DATE = __DATE__;
/**
* From the C99 standard:
* __TIME__: The time of translation of the preprocessing translation unit:
* a character string literal of the form "hh:mm:ss" as in the time
* generated by the asctime function. If the time of translation is not
* available, an implementation-defined valid time shall be supplied.
*/
const char *Version::BUILD_TIME = __TIME__;
QDateTime Version::buildDateTime()
{
static QDateTime buildDateTime;
if (!buildDateTime.isValid()) {
// Convert BUILD_DATE to a QDate
// The __DATE__ macro return the month name with the asctime() function,
// which doesn't support localization, the month names returned are
// always the same. On the contrary, the "MMM" format on
// QDate::fromString() is localized, so this method can't be used to
// retrieve the month and we must manually do it instead.
QString buildDateStr = QString(BUILD_DATE);
QString buildMonthStr = buildDateStr.left(3);
QString buildDayAndYearStr = buildDateStr.mid(4).trimmed();
QDate buildDate = QDate::fromString(buildDayAndYearStr, "d yyyy");
QStringList monthList = QStringList() << "Jan"
<< "Feb"
<< "Mar"
<< "Apr"
<< "May"
<< "Jun"
<< "Jul"
<< "Aug"
<< "Sep"
<< "Oct"
<< "Nov"
<< "Dec";
for (int i = 0; i < monthList.size(); ++i) {
if (buildMonthStr == monthList.at(i)) {
buildDate.setDate(buildDate.year(), i + 1, buildDate.day());
break;
}
}
// Convert BUILD_TIME to a QTime
QTime buildTime = QTime::fromString(BUILD_TIME, "hh:mm:ss");
// Set the buildDateTime
buildDateTime.setDate(buildDate);
buildDateTime.setTime(buildTime);
}
return buildDateTime;
}
} // namespace sciqlop