void AddToPyDict(python_ptr<PyObject> &dict, char* name, const TTime& value) { TDateTime epoch; epoch.Set(1970, EJanuary, 0, 0, 0, 0, 0); TTime e(epoch); TInt unixtime=0; TTimeIntervalSeconds secs; if (value!=TTime(0)) { User::LeaveIfError(value.SecondsFrom(e, secs)); unixtime=secs.Int(); } AddToPyDict(dict, name, unixtime); }
static void as_ttime (const struct tm& p, TTime& res, TBool normalise=EFalse) { TDateTime dt; TInt err = dt.Set(p.tm_year+1900, (enum TMonth)p.tm_mon, p.tm_mday-1, p.tm_hour, p.tm_min, p.tm_sec, 0); if (err == KErrNone) { res = dt; return; } if (!normalise) { res = TInt64(-1); return; } // Try to normalise things (for mktime) dt.Set(p.tm_year+1900, EJanuary, 0, 0, 0, 0, 0); res = dt; res += TTimeIntervalMonths (p.tm_mon); res += TTimeIntervalDays (p.tm_mday-1); res += TTimeIntervalHours (p.tm_hour); res += TTimeIntervalMinutes(p.tm_min); res += TTimeIntervalSeconds(p.tm_sec); }
void CSysApSimChanged::ClearLogsL() { TRACES( RDebug::Print( _L("CSysApSimChanged::ClearLogsL()") ) ); // Clear the event log. CShareActive* active = new (ELeave) CShareActive; CleanupStack::PushL( active ); active->StartL(); TDateTime dateTime; dateTime.Set( 2100, EJanuary, 1, 0, 0, 0, 0 ); TTime date(dateTime); /* TRACES( RDebug::Print( _L("CSysApSimChanged::ClearLogsL(): trying CLogClient::NewL") ) ); CLogClient* logClient = CLogClient::NewL( iFs ); logClient->ClearLog( date, active->iStatus ); */ CActiveScheduler::Start(); // delete logClient; CleanupStack::PopAndDestroy( active ); }
/*! Returns localized string representation of given \a date formatted with Symbian locale date format. If \a short_format is true the format will be a short version. Otherwise it uses a longer version. */ static QString symbianDateToString(const QDate &date, bool short_format) { int month = date.month() - 1; int day = date.day() - 1; int year = date.year(); TDateTime dateTime; dateTime.Set(year, TMonth(month), day, 0, 0, 0, 0); TTime timeStr(dateTime); TBuf<KMaxLongDateFormatSpec*2> buffer; TPtrC dateFormat; if (short_format) { dateFormat.Set(ptrGetShortDateFormatSpec(_s60Locale)); } else { dateFormat.Set(ptrGetLongDateFormatSpec(_s60Locale)); } TRAPD(err, ptrTimeFormatL(timeStr, buffer, dateFormat, *_s60Locale.GetLocale());) if (err == KErrNone)
TBool CDataWrapperBase::GetDateTimeFromConfig(const TDesC& aSectName, TDateTime& aResult) { TInt year , month , day , hour , minute, second, microsecond ; // Fields _LIT(KYear, "year"); _LIT(KMonth, "month"); _LIT(KDay, "day"); _LIT(KHour, "hour"); _LIT(KMinute, "minute"); _LIT(KSecond, "second"); _LIT(KMicrosecond, "microsecond"); TBool ret = ETrue ; if ( !GetIntFromConfig( aSectName, KYear , year)) { ret=EFalse; } if ( !GetIntFromConfig( aSectName, KMonth , month)) { ret=EFalse; } if ( !GetIntFromConfig( aSectName, KDay, day)) { ret=EFalse; } if ( !GetIntFromConfig( aSectName, KHour, hour)) { ret=EFalse; } if ( !GetIntFromConfig( aSectName, KMinute , minute)) { ret=EFalse; } if ( !GetIntFromConfig( aSectName, KSecond , second)) { ret=EFalse; } if ( !GetIntFromConfig( aSectName, KMicrosecond , microsecond)) { ret=EFalse; } if ( ret ) { TMonth amonth ; switch (month) { case 1: amonth = EJanuary ; break ; case 2: amonth = EFebruary ; break ; case 3 : amonth = EMarch ; break ; case 4: amonth = EApril ; break ; case 5: amonth = EMay ; break ; case 6 : amonth = EJune ; break ; case 7 : amonth = EJuly ; break ; case 8 : amonth = EAugust ; break ; case 9 : amonth = ESeptember ; break ; case 10 : amonth = EOctober ; break ; case 11 : amonth = ENovember ; break ; case 12: amonth = EDecember ; break ; default : return ret ; } aResult.Set(year,amonth ,day,hour,minute,second,microsecond); } return ret ; }