Пример #1
0
void CEstEIDCertificate::loadCertContexts(PCCERT_CONTEXT certContext) {
	USES_CONVERSION;
	CryptoErrorHandler(CertGetNameString(certContext, CERT_NAME_ATTR_TYPE, 0, szOID_COMMON_NAME, this->CN, 64));
	std::string s = W2A(this->CN);
	EstEID_log("Certificate = %s", s.c_str());
		
	CryptoErrorHandler(CertGetNameString(certContext, CERT_NAME_ATTR_TYPE, CERT_NAME_ISSUER_FLAG, szOID_COMMON_NAME, this->issuerCN, 64));

	std::stringstream buf;
	for(size_t i = certContext->pCertInfo->SerialNumber.cbData ; i > 0  ;i--) 
		buf << std::hex << std::setfill('0') << std::setw(2) << (int) certContext->pCertInfo->SerialNumber.pbData[i-1] << " ";
	std::string strBuf = buf.str();
	EstEID_log("serial=%s", strBuf.c_str());

	this->validFrom = dateToString(&certContext->pCertInfo->NotBefore);
	this->validTo = dateToString(&certContext->pCertInfo->NotAfter);

	this->certificate = (BYTE*)malloc(certContext->cbCertEncoded + 1);
	memcpy(this->certificate, certContext->pbCertEncoded, certContext->cbCertEncoded);
	this->certificate[certContext->cbCertEncoded] = '\0';
	EstEID_log("certificate binary length = %i", certContext->cbCertEncoded);
	
	calculateMD5Hash(certContext->cbCertEncoded);
	binCert2Hex(certContext->cbCertEncoded);
}
Пример #2
0
void
TimeZoneBoundaryTest::findDaylightBoundaryUsingDate(UDate d, const char* startMode, UDate expectedBoundary)
{
    UnicodeString str;
    if (dateToString(d, str).indexOf(startMode) == - 1) {
        logln(UnicodeString("Error: ") + startMode + " not present in " + str);
    }
    UDate min = d;
    UDate max = min + SIX_MONTHS;
    while ((max - min) > INTERVAL) {
        UDate mid = (min + max) / 2;
        UnicodeString* s = &dateToString(mid, str);
        if (s->indexOf(startMode) != - 1) {
            min = mid;
        }
        else {
            max = mid;
        }
    }
    logln("Date Before: " + showDate(min));
    logln("Date After:  " + showDate(max));
    UDate mindelta = expectedBoundary - min;
    UDate maxdelta = max - expectedBoundary;
    if (mindelta >= 0 &&
        mindelta <= INTERVAL &&
        maxdelta >= 0 &&
        maxdelta <= INTERVAL) logln(UnicodeString("PASS: Expected boundary at ") + expectedBoundary);
    else dataerrln(UnicodeString("FAIL: Expected boundary at ") + expectedBoundary);
}
Пример #3
0
void
TimeZoneBoundaryTest::testUsingBinarySearch(SimpleTimeZone* tz, UDate d, UDate expectedBoundary)
{
    UErrorCode status = U_ZERO_ERROR;
    UDate min = d;
    UDate max = min + SIX_MONTHS;
    UBool startsInDST = tz->inDaylightTime(d, status);
    if (failure(status, "SimpleTimeZone::inDaylightTime", TRUE)) return;
    if (tz->inDaylightTime(max, status) == startsInDST) {
        errln("Error: inDaylightTime(" + dateToString(max) + ") != " + ((!startsInDST)?"true":"false"));
    }
    if (failure(status, "SimpleTimeZone::inDaylightTime")) return;
    while ((max - min) > INTERVAL) {
        UDate mid = (min + max) / 2;
        if (tz->inDaylightTime(mid, status) == startsInDST) {
            min = mid;
        }
        else {
            max = mid;
        }
        if (failure(status, "SimpleTimeZone::inDaylightTime")) return;
    }
    logln("Binary Search Before: " + showDate(min));
    logln("Binary Search After:  " + showDate(max));
    UDate mindelta = expectedBoundary - min;
    UDate maxdelta = max - expectedBoundary;
    if (mindelta >= 0 &&
        mindelta <= INTERVAL &&
        maxdelta >= 0 &&
        maxdelta <= INTERVAL) logln(UnicodeString("PASS: Expected boundary at ") + expectedBoundary);
    else errln(UnicodeString("FAIL: Expected boundary at ") + expectedBoundary);
}
Пример #4
0
void MyMoneySplit::writeXML(QDomDocument& document, QDomElement& parent) const
{
  QDomElement el = document.createElement("SPLIT");

  writeBaseXML(document, el);

  el.setAttribute("payee", m_payee);
  //el.setAttribute("tag", m_tag);
  el.setAttribute("reconciledate", dateToString(m_reconcileDate));
  el.setAttribute("action", m_action);
  el.setAttribute("reconcileflag", m_reconcileFlag);
  el.setAttribute("value", m_value.toString());
  el.setAttribute("shares", m_shares.toString());
  if (!m_price.isZero())
    el.setAttribute("price", m_price.toString());
  el.setAttribute("memo", m_memo);
  // No need to write the split id as it will be re-assigned when the file is read
  // el.setAttribute("id", split.id());
  el.setAttribute("account", m_account);
  el.setAttribute("number", m_number);
  el.setAttribute("bankid", m_bankID);

  for (int i = 0; i < m_tagList.count(); i++) {
    QDomElement sel = document.createElement("TAG");
    sel.setAttribute("id", m_tagList[i]);
    el.appendChild(sel);
  }

  MyMoneyKeyValueContainer::writeXML(document, el);

  parent.appendChild(el);
}
Пример #5
0
static void writePageFooter(QTextStream &t,const QCString &lastTitle,
                            const QCString relPath)
{
  if (g_footer.isEmpty())
  {
    t << "<hr size=\"1\"><address style=\"align: right;\"><small>";
    t << theTranslator->trGeneratedAt(
        dateToString(TRUE),
        Config_getString("PROJECT_NAME")
        );
    t << "&nbsp;" << endl << "<a href=\"http://www.doxygen.org/index.html\">";
    t << endl << "<img src=\"" << relPath << "doxygen.png\" alt=\"doxygen\" " 
      << "align=\"middle\" border=\"0\">" << "</a> " << versionString << " ";
    t << "</small></address>";
    if (Debug::isFlagSet(Debug::Validate))
    {
      t << "<p><a href=\"http://validator.w3.org/check/referer\">"
           "<img border=\"0\" src=\"http://www.w3.org/Icons/valid-html401\""
           " height=\"31\" width=\"88\" alt=\"This page is Valid HTML 4.01 "
           "Transitional!\"></a><a href=\"http://jigsaw.w3.org/css-validator/\">"
           "<img style=\"border:0;width:88px;height:31px\" "
           "src=\"http://jigsaw.w3.org/css-validator/images/vcss\" "
           "alt=\"This page uses valid CSS!\"></a></p>";
    }
    t << "\n</body>\n</html>\n";
  }
  else
  {
    t << substituteKeywords(g_footer,convertToHtml(lastTitle),relPath);
  }
}
Пример #6
0
void
TimeZoneBoundaryTest::verifyDST(UDate d, TimeZone* time_zone, UBool expUseDaylightTime, UBool expInDaylightTime, UDate expZoneOffset, UDate expDSTOffset)
{
    UnicodeString str;
    UErrorCode status = U_ZERO_ERROR;
    logln("-- Verifying time " + dateToString(d) + " in zone " + time_zone->getID(str));
    if (time_zone->inDaylightTime(d, status) == expInDaylightTime)
        logln(UnicodeString("PASS: inDaylightTime = ") + (time_zone->inDaylightTime(d, status)?"true":"false"));
    else 
        dataerrln(UnicodeString("FAIL: inDaylightTime = ") + (time_zone->inDaylightTime(d, status)?"true":"false"));
    if (failure(status, "TimeZone::inDaylightTime", TRUE)) 
        return;
    if (time_zone->useDaylightTime() == expUseDaylightTime)
        logln(UnicodeString("PASS: useDaylightTime = ") + (time_zone->useDaylightTime()?"true":"false"));
    else 
        dataerrln(UnicodeString("FAIL: useDaylightTime = ") + (time_zone->useDaylightTime()?"true":"false"));
    if (time_zone->getRawOffset() == expZoneOffset) 
        logln(UnicodeString("PASS: getRawOffset() = ") + (expZoneOffset / ONE_HOUR));
    else
        dataerrln(UnicodeString("FAIL: getRawOffset() = ") + (time_zone->getRawOffset() / ONE_HOUR) + ";  expected " + (expZoneOffset / ONE_HOUR));
    
    GregorianCalendar *gc = new GregorianCalendar(time_zone->clone(), status);
    gc->setTime(d, status);
    if (failure(status, "GregorianCalendar::setTime")) return;
    int32_t offset = time_zone->getOffset((uint8_t)gc->get(UCAL_ERA, status),
        gc->get(UCAL_YEAR, status), gc->get(UCAL_MONTH, status),
        gc->get(UCAL_DATE, status), (uint8_t)gc->get(UCAL_DAY_OF_WEEK, status),
        ((gc->get(UCAL_HOUR_OF_DAY, status) * 60 + gc->get(UCAL_MINUTE, status)) * 60 + gc->get(UCAL_SECOND, status)) * 1000 + gc->get(UCAL_MILLISECOND, status),
        status);
    if (failure(status, "GregorianCalendar::get")) return;
    if (offset == expDSTOffset) logln(UnicodeString("PASS: getOffset() = ") + (offset / ONE_HOUR));
    else dataerrln(UnicodeString("FAIL: getOffset() = ") + (offset / ONE_HOUR) + "; expected " + (expDSTOffset / ONE_HOUR));
    delete gc;
}
Пример #7
0
QVariant BondTableModel::data(const QModelIndex &index, int role) const {
    BondData bondData = bondDatas[index.row()];

    if (role == Qt::DisplayRole) {
        int column = index.column();
        if (column == 0) {
            return QString::fromStdString(dateToString(bondData.issueDate));
        } else if (column == 1) {
            return QString::fromStdString(dateToString(bondData.maturity));
        } else if (column == 2) {
            return QVariant(bondData.couponRate);
        } else if (column == 3) {
            return QVariant(bondData.marketQuote);
        }
    }
    return QVariant();
}
Пример #8
0
void QtDcmManager::findStudiesScu ( const QString &patientName )
{
    d->seriesToImport.clear();

    QtDcmFindScu * finder = new QtDcmFindScu ( this );
    finder->findStudiesScu ( patientName, d->studyDescription, dateToString(d->date1), dateToString(d->date2) );
    delete finder;
}
Пример #9
0
/**
 * Get a text representation of the date represented by the given integer.
 * (PortaBase stores a date YYYY-MM-DD as the integer with digits YYYYMMDD.)
 *
 * @param date The integer-encoded date to be formatted
 * @return The formatted date
 */
QString Formatting::dateToString(int date)
{
    int y = date / 10000;
    int m = (date - y * 10000) / 100;
    int d = date - y * 10000 - m * 100;
    QDate dateObj(y, m, d);
    return dateToString(dateObj);
}
Пример #10
0
void ItemViewImageDelegate::drawModificationDate(QPainter* p, const QRect& dateRect, const QDateTime& date) const
{
    Q_D(const ItemViewImageDelegate);

    p->setFont(d->fontXtra);
    QString str = dateToString(date);
    str         = i18nc("date of last image modification", "Mod.: %1",str);
    p->drawText(dateRect, Qt::AlignCenter, str);//squeezedTextCached(p, dateRect.width(), str));
}
Пример #11
0
void updateHD44780lcd(void) {

	lcd_HD44780_set_position(0, 9);
	/**
	 * this would blink so that we know the LCD is alive
	 */
	if (getTimeNowSeconds() % 2 == 0) {
		lcd_HD44780_print_char('R');
	} else {
		lcd_HD44780_print_char(' ');
	}
	lcd_HD44780_set_position(0, 10);

	char * ptr = itoa10(buffer, getRpm());
	ptr[0] = 0;
	int len = ptr - buffer;
	for (int i = 0; i < 6 - len; i++) {
		lcd_HD44780_print_char(' ');
	}
	lcd_HD44780_print_string(buffer);

	if (hasFirmwareError()) {
		memcpy(buffer, getFirmwareError(), LCD_WIDTH);
		buffer[LCD_WIDTH] = 0;
		lcd_HD44780_set_position(1, 0);
		lcd_HD44780_print_string(buffer);
		return;
	}

	lcd_HD44780_set_position(1, 0);
	memset(buffer, ' ', LCD_WIDTH);
	memcpy(buffer, getWarninig(), LCD_WIDTH);
	buffer[LCD_WIDTH] = 0;
	lcd_HD44780_print_string(buffer);

	if (engineConfiguration->HD44780height < 3) {
		return;
	}

	int index = (getTimeNowSeconds() / 2) % (NUMBER_OF_DIFFERENT_LINES / 2);

	prepareCurrentSecondLine(index);
	buffer[LCD_WIDTH] = 0;
	lcd_HD44780_set_position(2, 0);
	lcd_HD44780_print_string(buffer);

	prepareCurrentSecondLine(index + NUMBER_OF_DIFFERENT_LINES / 2);
	buffer[LCD_WIDTH] = 0;
	lcd_HD44780_set_position(3, 0);
	lcd_HD44780_print_string(buffer);

#if EFI_PROD_CODE
	dateToString(dateBuffer);
	lcd_HD44780_set_position(1, 0);
	lcd_HD44780_print_string(dateBuffer);
#endif /* EFI_PROD_CODE */
}
Пример #12
0
UnicodeString
TimeZoneBoundaryTest::showDate(UDate d)
{
    int32_t y, m, day, h, min, sec;
    dateToFields(d, y, m, day, h, min, sec);
    return UnicodeString("") + y + "/" + showNN(m + 1) + "/" +
        showNN(day) + " " + showNN(h) + ":" + showNN(min) +
        " \"" + dateToString(d) + "\" = " + uprv_floor(d+0.5);
}
Пример #13
0
void MyMoneyStorageXML::writeFileInformation(QDomElement& fileInfo)
{
  QDomElement creationDate = m_doc->createElement("CREATION_DATE");
  creationDate.setAttribute("date", dateToString(m_storage->creationDate()));
  fileInfo.appendChild(creationDate);

  QDomElement lastModifiedDate = m_doc->createElement("LAST_MODIFIED_DATE");
  lastModifiedDate.setAttribute("date", dateToString(m_storage->lastModificationDate()));
  fileInfo.appendChild(lastModifiedDate);

  QDomElement version = m_doc->createElement("VERSION");

  version.setAttribute("id", "1");
  fileInfo.appendChild(version);

  QDomElement fixVersion = m_doc->createElement("FIXVERSION");
  fixVersion.setAttribute("id", m_storage->fileFixVersion());
  fileInfo.appendChild(fixVersion);
}
Пример #14
0
void Calendar::navigationRightClicked()
{
    /* This function is used for navigation, to reach future range
       of days or previous month, or year. At first its getting real
       date, which is needed for initialization.*/
    if(!flag)
    {
        actualDate->getDate(&year,&month,&day);
        flag = true;
    }
    if(month==2 && year%4==0 && day>22 && flagFeb==1)
    {
        day = 29;
        flagFeb = 0;
    }
    else if(day<=22 && flagFeb==0)
         day = day + 7;
    else if (month<12)
    {
        month = month + 1;
        day = 1;
    }
    else
    {
        year = year +1;
        month = 1;
        day = 1;
    }
    /* This condition is showing weekday buttons, whenever flagHide is true.
       day buttons are hidden in sortButtons function below. */
    if(flagHide==1)
    {
        days[0]->show();
        days[1]->show();
        days[2]->show();
        days[3]->show();
        days[4]->show();
        days[5]->show();
        days[6]->show();
    }
    currentDateLabel = dateToString(day,month,year);
    dateLabel->setText("<center>" + currentDateLabel + "</center>");

    actualWeek=actualWeek+1;

    colorTask();

    sortButtons();

    // setting day dates

}
Пример #15
0
// Get XML Representation
const QString& Message::toXML() {

    if ( m_changed ) {
        const static QString endAttr( "\"" );
        QString xml = "<Message";
        QString dataMember;
            // check for presence of required  attribute
        if ( m_timeStampPresent) {
            xml.append(" TimeStamp=\"" + dateToString( m_timeStamp) + endAttr);
        } else { // required attribute not present
            m_lastError = "TimeStamp not set";
            m_store  = QString::null;
            return m_store;
        }
            // check for presence of required  attribute
        if ( m_codePresent) {
            xml.append(" Code=\"" + QString::number( m_code ) + endAttr);
        } else { // required attribute not present
            m_lastError = "Code not set";
            m_store  = QString::null;
            return m_store;
        }
            // check for presence of required  attribute
        if ( m_versionPresent) {
            xml.append(" Version=\"" + m_version + endAttr);
        } else { // required attribute not present
            m_lastError = "Version not set";
            m_store  = QString::null;
            return m_store;
        }
        xml.append(">\n");
        if (m_arguments.count() < 0) {
            m_lastError = "not enough Argument values";
            m_store  = QString::null;
            return m_store;
        }
        if (m_arguments.count() > 10) {
            m_lastError = "too much Argument values";
            m_store  = QString::null;
            return m_store;
        }
        // add all included data
        for(int i=0; i < m_arguments.count(); i++ ) {
            QString attribute = m_arguments.at(i);
            xml.append( "<Argument>" + encode (attribute) +  "</Argument>" );
        }
        xml.append( "</Message>\n");
        m_store = xml;
        m_changed = false;
    }
    return m_store;
}
Пример #16
0
void
TimeZoneBoundaryTest::findDaylightBoundaryUsingTimeZone(UDate d, UBool startsInDST, UDate expectedBoundary, TimeZone* tz)
{
    UErrorCode status = U_ZERO_ERROR;
    UnicodeString str;
    UDate min = d;
    UDate max = min + SIX_MONTHS;
    if (tz->inDaylightTime(d, status) != startsInDST) {
        dataerrln("FAIL: " + tz->getID(str) + " inDaylightTime(" + dateToString(d) + ") != " + (startsInDST ? "true" : "false"));
        startsInDST = !startsInDST;
    }
    if (failure(status, "TimeZone::inDaylightTime", TRUE)) return;
    if (tz->inDaylightTime(max, status) == startsInDST) {
        dataerrln("FAIL: " + tz->getID(str) + " inDaylightTime(" + dateToString(max) + ") != " + (startsInDST ? "false" : "true"));
        return;
    }
    if (failure(status, "TimeZone::inDaylightTime")) return;
    while ((max - min) > INTERVAL) {
        UDate mid = (min + max) / 2;
        UBool isIn = tz->inDaylightTime(mid, status);
        if (failure(status, "TimeZone::inDaylightTime")) return;
        if (isIn == startsInDST) {
            min = mid;
        }
        else {
            max = mid;
        }
    }
    logln(tz->getID(str) + " Before: " + showDate(min));
    logln(tz->getID(str) + " After:  " + showDate(max));
    UDate mindelta = expectedBoundary - min;
    UDate maxdelta = max - expectedBoundary;
    if (mindelta >= 0 &&
        mindelta <= INTERVAL &&
        maxdelta >= 0 &&
        maxdelta <= INTERVAL) logln(UnicodeString("PASS: Expected boundary at ") + expectedBoundary);
    else errln(UnicodeString("FAIL: Expected boundary at ") + expectedBoundary);
}
Пример #17
0
void viewTransaction(Transaction* tx) {
  textArea text;
  if(tx->credit) {
    text.title = (char*)"Credit information";
  } else {
    text.title = (char*)"Debit information";
  }
  text.allowLeft = 1;
  
  textElement elem[15];
  text.elements = elem;
  text.numelements = 0; //we will use this as element cursor
  
  elem[text.numelements].text = (char*)"Description:";
  elem[text.numelements].color=COLOR_LIGHTGRAY;
  elem[text.numelements].spaceAtEnd=1;
  text.numelements++;
  
  elem[text.numelements].text = tx->description;
  text.numelements++;
    
  elem[text.numelements].text = (char*)"Date & time:";
  elem[text.numelements].newLine = 1;
  elem[text.numelements].spaceAtEnd=1;
  elem[text.numelements].color=COLOR_LIGHTGRAY; 
  text.numelements++;
  
  char date[50];
  dateToString(date, tx->date.year, tx->date.month, tx->date.day);
  strcat(date, (char*)" ");
  // timeToString concatenates
  timeToString(date, tx->time.hour, tx->time.minute, tx->time.second);
  
  elem[text.numelements].text = date;
  text.numelements++;
  
  char amount[20];
  currencyToString(amount, &tx->amount);

  elem[text.numelements].text = (char*)"Amount:";
  elem[text.numelements].newLine = 1;
  elem[text.numelements].spaceAtEnd=1;
  elem[text.numelements].color=COLOR_LIGHTGRAY;
  text.numelements++;
  
  elem[text.numelements].text = amount;
  text.numelements++;

  doTextArea(&text);
}
Пример #18
0
// Get String Representation with a lead
QString Message::toString(QString lead) const{

    const static QString endAttr( "\n" );
    QString str = lead + "Message\n";
    str.append( lead + "    TimeStamp = " + dateToString( m_timeStamp) + endAttr);
    str.append( lead + "    Code = " + QString::number( m_code ) + endAttr);
    str.append( lead + "    Version = " + m_version + endAttr);
    // add all included data
    for(int i=0; i < m_arguments.count(); i++ ) {
        QString attribute = m_arguments.at(i);
        str.append( lead + "    " + attribute );
    }
    return str;
}
Пример #19
0
/**
 * @bug 4134203
 * SimpleDateFormat won't parse "GMT"
 */
void DateFormatRegressionTest::Test4134203(void) 
{
    UErrorCode status = U_ZERO_ERROR;
    UnicodeString dateFormat = "MM/dd/yy HH:mm:ss zzz";
    SimpleDateFormat *fmt = new SimpleDateFormat(dateFormat, status);
    if (failure(status, "new SimpleDateFormat", TRUE)) return;
    ParsePosition p0(0);
    UDate d = fmt->parse("01/22/92 04:52:00 GMT", p0);
    logln(dateToString(d));
    if(p0 == ParsePosition(0))
        errln("Fail: failed to parse 'GMT'");
    // In the failure case an exception is thrown by parse();
    // if no exception is thrown, the test passes.

    delete fmt;
}
Пример #20
0
void ManGenerator::endTitleHead(const char *,const char *name)
{
  t << ".TH \"" << name << "\" " << getExtension() << " \"" 
    << dateToString(FALSE) << "\" \"";
  if (!Config_getString("PROJECT_NUMBER").isEmpty())
    t << "Version " << Config_getString("PROJECT_NUMBER") << "\" \"";
  if (Config_getString("PROJECT_NAME").isEmpty()) 
    t << "Doxygen";
  else
    t << Config_getString("PROJECT_NAME");
  t << "\" \\\" -*- nroff -*-" << endl;
  t << ".ad l" << endl;
  t << ".nh" << endl;
  t << ".SH NAME" << endl;
  t << name << " \\- ";
  firstCol=FALSE;
  inHeader=TRUE;
}
Пример #21
0
/**
 * @bug 4101483
 */
void DateFormatRegressionTest::Test4101483(void) 
{
    UErrorCode status = U_ZERO_ERROR;
    SimpleDateFormat *sdf = new SimpleDateFormat(UnicodeString("z"), Locale::getUS(), status);
    if (failure(status, "new SimpleDateFormat", TRUE)) return;
    FieldPosition fp(UDAT_TIMEZONE_FIELD);
    //Date d = date(9234567890L);
    UDate d = 9234567890.0;
    //StringBuffer buf = new StringBuffer("");
    UnicodeString buf;
    sdf->format(d, buf, fp);
    //logln(sdf.format(d, buf, fp).toString());
    logln(dateToString(d) + " => " + buf);
    logln("beginIndex = " + fp.getBeginIndex());
    logln("endIndex = " + fp.getEndIndex());
    if (fp.getBeginIndex() == fp.getEndIndex()) 
        errln("Fail: Empty field");

    delete sdf;
}
void EventTimelineDatePainter::paintDate(const QDate &date)
{
    QDateTime dt = QDateTime(date, QTime(), Qt::UTC);

    if (m_visibleTimeStart >= dt.addDays(1))
        return;

    QString dateStr = dateToString(date);
    QRect dateRect = dateStringToRect(date, dateStr);

    if (isRectUnused(dateRect))
    {
        paintDateString(dateStr, dateRect);
        if (shouldPaintUndrawnDate())
            paintDateString(m_undrawnDateString, m_undrawnDateRect);
        setUndrawnDateString(QString(), QRect());
    }
    else
        setUndrawnDateString(dateStr, dateRect.translated(m_lastDrawnDateRect.right() - dateRect.left(), 0));

    m_useLongDateFormat = false;
}
Пример #23
0
/**
 * @bug 4103340
 * @bug 4138203
 * This bug really only works in Locale.US, since that's what the locale
 * used for Date.toString() is.  Bug 4138203 reports that it fails on Korean
 * NT; it would actually have failed on any non-US locale.  Now it should
 * work on all locales.
 */
void DateFormatRegressionTest::Test4103340(void) 
{
    UErrorCode status = U_ZERO_ERROR;

    // choose a date that is the FIRST of some month 
    // and some arbitrary time 
    UDate d = date(97, 3, 1, 1, 1, 1); 
    SimpleDateFormat *df = new SimpleDateFormat(UnicodeString("MMMM"), Locale::getUS(), status); 
    if (failure(status, "new SimpleDateFormat", TRUE)) return;

    UnicodeString s;
    s = dateToString(d, s);
    UnicodeString s2;
    FieldPosition pos(FieldPosition::DONT_CARE);
    s2 = df->format(d, s2, pos);
    logln("Date=" + s); 
    logln("DF=" + s2);
    UnicodeString substr;
    s2.extract(0,2, substr);
    if (s.indexOf(substr) == -1)
      errln("Months should match");
    
    delete df;
}
Пример #24
0
QString DateUtils::convertToAppSettingsFormatStr(const double valueToFormat){
    return dateToString(convertToAppSettingsFormat(valueToFormat));
}
Пример #25
0
void currentDateToString(char *buffer, int format) {
  dateToString(buffer, getCurrentYear(), getCurrentMonth(), getCurrentDay(), format);
}
Пример #26
0
void XML::WriteNode(Data data)
{

	MAUtil::String coords_tag = "<Point>\n";

	maFileWrite(file, coords_tag.c_str(), coords_tag.size());

	coords_tag = "	<Coords>\n";

	maFileWrite(file, coords_tag.c_str(), coords_tag.size());

	//Write the Lan and Lon values.
	coords_tag = "		<Lat>";
	maFileWrite(file, coords_tag.c_str(), coords_tag.size());

	MAUtil::String data2;
	data2 = MAUtil::doubleToString(data.loc.lat);

	maFileWrite(file, data2.c_str(), data2.size());

	coords_tag = "</Lat>\n";
	maFileWrite(file, coords_tag.c_str(), coords_tag.size());


	coords_tag = "		<Lon>";
	maFileWrite(file, coords_tag.c_str(), coords_tag.size());

	data2 = MAUtil::doubleToString(data.loc.lon);

	maFileWrite(file, data2.c_str(), data2.size());

	coords_tag = "</Lon>\n";
	maFileWrite(file, coords_tag.c_str(), coords_tag.size());
	//
	coords_tag = "	</Coords>\n";

	maFileWrite(file, coords_tag.c_str(), coords_tag.size());


	if(data.imagePath.size() > 0)
	{
		_ActivityIndicator->show();

		byte *tdata;
		int dataLen;
		MAUtil::String img_tag = "	<Image>";


		lprintfln("Image file: %s", data.imagePath.c_str());

		maFileWrite(file, img_tag.c_str(), img_tag.size());
		//maFileWrite(file, data.imagePath.c_str(), data.imagePath.size());
		//Write the data to the xml

		if(!writeDataToXML(data.imagePath))
		{
			maPanic(0, "Couldn't locate the image file.");
		}

		//maFileWrite(file, tdata, dataLen);
		//End of data writting.

		img_tag = "</Image>\n";

		maFileWrite(file, img_tag.c_str(), img_tag.size());

		_ActivityIndicator->hide();
	}


	if(data.videoPath.size() > 0)
	{
		_ActivityIndicator->show();

		byte *tdata;
		int dataLen;
		MAUtil::String vid_tag = "	<Video>";

		maFileWrite(file, vid_tag.c_str(), vid_tag.size());
		//maFileWrite(file, data.videoPath.c_str(), data.videoPath.size());
		//Write the data to the xml

		lprintfln("Image file: %s", data.videoPath.c_str());

		if(!writeDataToXML(data.videoPath))
		{
			maPanic(0, "Couldn't locate the video file.");
		}

		//maFileWrite(file, tdata, dataLen);
		//End of data writting.

		vid_tag = "</Video>\n";

		maFileWrite(file, vid_tag.c_str(), vid_tag.size());

		_ActivityIndicator->hide();
	}

	if(data.text.size() > 0)
	{
		MAUtil::String text_tag = "	<Text>";

		maFileWrite(file, text_tag.c_str(), text_tag.size());
		maFileWrite(file, data.text.c_str(), data.text.size());

		text_tag = "</Text>\n";

		maFileWrite(file, text_tag.c_str(), text_tag.size());
	}


	//Write the date time.
	coords_tag = "	<DateTime>";

	maFileWrite(file, coords_tag.c_str(), coords_tag.size());

	coords_tag = dateToString(data.time);

	maFileWrite(file, coords_tag.c_str(), coords_tag.size());

	coords_tag = "</DateTime>\n";

	maFileWrite(file, coords_tag.c_str(), coords_tag.size());

	//End of date time.

	coords_tag = "</Point>";
	maFileWrite(file, coords_tag.c_str(), coords_tag.size());
}
Пример #27
0
/**
 * Get a human-readable time string from the given date-time object.
 *
 * @param dateTime The date and time to be formatted
 * @return A human-readable date + time string
 */
QString Formatting::dateTimeToString(const QDateTime &dateTime)
{
    QString date = dateToString(dateTime.date());
    QString time = dateTime.time().toString(timeFormat);
    return QString("%1 %2").arg(date).arg(time);
}
Пример #28
0
QString DateUtils::convertFromAppSettingsFormatStr(const double formattedValue){
    return dateToString(convertFromAppSettingsFormat(formattedValue));
}
Пример #29
0
Calendar::Calendar()
{
    eventListCounter = 0;
    loadEvents();

    actualDate = new QDate;
    *actualDate = QDate::currentDate();                      //get's information about current date and sets proper label
    int actualDay, actualMonth, actualYear;
    actualDate->getDate(&actualDay, &actualMonth, &actualYear);

    // essential variables initialization

    actualDate->getDate(&year,&month,&day);
    QDate dayOfWeek(year,month,1);      //gets information about first day of selected month and year
    whatDay = dayOfWeek.dayOfWeek();

    // end of essential variables initialization

    actualWeek = actualDate->weekNumber();

    // future note: array are better than days[0], days[1], days[2]... :P

    days = new Day*[7];

    days[0] = new Day("Monday");
    days[1] = new Day("Tuesday");
    days[2] = new Day("Wednesday");
    days[3] = new Day("Thursday");
    days[4] = new Day("Friday");
    days[5] = new Day("Saturday");
    days[6] = new Day("Sunday");


    daysLayout = new QHBoxLayout;

    navigationLayout = new QHBoxLayout;            // horizontal layout for navigation elements

    // creating elements for navigation box
    navigationLeft = new QPushButton("<<");
    navigationRight = new QPushButton(">>");
    dateLabel = new QLabel();                       // QLabel initialization

    navigationLayout->addWidget(navigationLeft);
    navigationLayout->addWidget(dateLabel);
    navigationLayout->addWidget(navigationRight);

    mainLayout = new QVBoxLayout;                  // vertical layout for navigation and days boxes
    mainLayout->addLayout(navigationLayout);
    mainLayout->addLayout(daysLayout);
    this->setLayout(mainLayout);

    QString initialDateLabel = dateToString(actualYear, actualMonth, actualDay);
    dateLabel->setText("<center>" + initialDateLabel + "</center>");
    sortButtons();
    connect(navigationLeft,SIGNAL(pressed()),this,SLOT(navigationLeftClicked()));   //connects navigation buttons with action (changing day's range or month)
    connect(navigationRight,SIGNAL(pressed()),this,SLOT(navigationRightClicked()));


/* Signal mapper is used to send parameter to slot method. The parameter here is
 * integer which reprenets offset of certain days of week. */

    QSignalMapper* signalMapper = new QSignalMapper(this);              // signal mapping is needed to parametrize slot :(

    connect(days[0], SIGNAL(pressed()), signalMapper, SLOT(map()));
    connect(days[1], SIGNAL(pressed()), signalMapper, SLOT(map()));
    connect(days[2], SIGNAL(pressed()), signalMapper, SLOT(map()));
    connect(days[3], SIGNAL(pressed()), signalMapper, SLOT(map()));
    connect(days[4], SIGNAL(pressed()), signalMapper, SLOT(map()));
    connect(days[5], SIGNAL(pressed()), signalMapper, SLOT(map()));
    connect(days[6], SIGNAL(pressed()), signalMapper, SLOT(map()));

    signalMapper->setMapping(days[0], 0);
    signalMapper->setMapping(days[1], 1);
    signalMapper->setMapping(days[2], 2);
    signalMapper->setMapping(days[3], 3);
    signalMapper->setMapping(days[4], 4);
    signalMapper->setMapping(days[5], 5);
    signalMapper->setMapping(days[6], 6);

    connect(signalMapper, SIGNAL(mapped(int)), this, SLOT(scheduleDay(int)));

    colorTask();
}
Пример #30
0
    std::ostream& error() {
	std::cerr << "--- ERROR -- [" << dateToString() << "]" ;
	return std::cerr;
    }