本文整理汇总了C++中TDateTime::Year方法的典型用法代码示例。如果您正苦于以下问题:C++ TDateTime::Year方法的具体用法?C++ TDateTime::Year怎么用?C++ TDateTime::Year使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TDateTime
的用法示例。
在下文中一共展示了TDateTime::Year方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetRulesL
//
// Gets the encoded rules for the current standard time alignment, between aStartDateTime and aEndDateTime
//
void CTzDbRuleSet::GetRulesL(CTzRules& aTzRules, TInt aUtcOffset, const TDateTime& aStartDateTime, const TDateTime& aEndDateTime) const
{
TInt startYear = aStartDateTime.Year();
// the last year we are interested in is the earliest of the following:
// 1) the last year of the CTzRules
// 2) the year of aEndDateTime (the end of the invoking std time alignment)
TInt endYear = (aEndDateTime.Year() < aTzRules.EndYear())
? aEndDateTime.Year() : aTzRules.EndYear();
const TDateTime rulesEndDateTime(aTzRules.EndYear(), EDecember, 30, 0,0,0,0);
const TDateTime& endDateTime = (aEndDateTime.Year() <= aTzRules.EndYear())
? aEndDateTime : rulesEndDateTime;
RArray<TTzRuleDefinition*> ruleDefs;
CleanupClosePushL(ruleDefs); // PUSH #1
RArray<TTzRuleUse*> ruleUses;
CleanupClosePushL(ruleUses); // PUSH #2
FetchRuleDefinitionsL(ruleDefs,ruleUses,startYear,endYear);
// fetch rules for previous year (these will be needed to work out the "Old Offset" field of
// the first rule in aStartYear
TInt initialLocalTimeOffset = GetLocalTimeOffsetAtEndOfYearL(startYear-1,aUtcOffset);
// convert rule definitions (together with rule uses) to TTzRules and add them to aTzRules
CompleteRulesAndAddToCollectionL(aTzRules,ruleDefs,ruleUses,aUtcOffset,initialLocalTimeOffset,aStartDateTime,endDateTime);
CleanupStack::PopAndDestroy(2,&ruleDefs); // POP #2,#1 - ruleUses, ruleDefs
}
示例2: GetEventInformation
// ----------------------------------------------------
// CAlfExCalendarEngine::NumberOfEvents
// ----------------------------------------------------
void CAlfExCalendarEngine::GetEventInformation(
const TTime& aDate,
TInt aIndex,
TDes& aTextBuffer)
{
aTextBuffer.Zero();
TInt count = KErrNotFound;
TDateTime requestedDate = aDate.DateTime();
const TInt arrayCount = iCalendarEventArray.Count();
for(TInt loop = 0; loop < arrayCount; loop++ )
{
TDateTime eventDate = iCalendarEventArray[loop].iItemDay.DateTime();
if(eventDate.Day() == requestedDate.Day() &&
eventDate.Month() == requestedDate.Month() &&
eventDate.Year() == requestedDate.Year())
{
count++;
}
if(aIndex == count)
{
aTextBuffer.Copy(iCalendarEventArray[loop].iItemText);
loop = arrayCount;
}
}
}
示例3: CompareDate
TBool CHttpHdrTest::CompareDate(TDateTime aDate1, TDateTime aDate2)
{
return ((aDate1.Year() == aDate2.Year()) &&
(aDate1.Month() == aDate2.Month()) &&
(aDate1.Day() == aDate2.Day()) &&
(aDate1.Hour() == aDate2.Hour()) &&
(aDate1.Minute() == aDate2.Minute()) &&
(aDate1.Second() == aDate2.Second()) &&
(aDate1.MicroSecond() == aDate2.MicroSecond()));
}
示例4: WriteSolutionTagL
// -----------------------------------------------------------------------------
// CCapInfo::WriteSolutionTagL()
// Writes SyncSolutionsService solution data to capability object.
// -----------------------------------------------------------------------------
//
void CCapInfo::WriteSolutionTagL( const TDesC& aContentName,
const TSConSolutionInfo& aSolution )
{
TRACE_FUNC_ENTRY;
_LIT( KFormatUID, "UID=0x%08x" );
_LIT( KFormatName, "Name=%S" );
_LIT( KFormatDate, "Timestamp=%04d%02d%02dT%02d%02d%02dZ" );
WriteTagL( EExt, TXmlParser::EElementBegin );
WriteValueL( EXNam, aContentName );
TFileName temp;
temp.Format( KFormatUID, aSolution.iUid );
WriteValueL( EXVal, temp );
temp.Format( KFormatName, &aSolution.iSolutionName );
WriteValueL( EXVal, temp );
if ( aSolution.iTime.Int64() != 0 )
{
// write time
TDateTime time = aSolution.iTime.DateTime();
temp.Format( KFormatDate, time.Year(), time.Month() + 1,
time.Day() + 1, time.Hour(), time.Minute(), time.Second() );
WriteValueL( EXVal, temp );
}
WriteTagL( EExt, TXmlParser::EElementEnd );
TRACE_FUNC_EXIT;
}
示例5: FormatTimeSimple
void MemSpyEngineUtils::FormatTimeSimple( TDes& aBuf, const TTime& aTime )
{
const TDateTime dt = aTime.DateTime();
//
_LIT( KTimeFormatSpec, "%04d%02d%02d %02d:%02d:%02d" );
aBuf.Format( KTimeFormatSpec, dt.Year(), dt.Month()+1, dt.Day()+1, dt.Hour(), dt.Minute(), dt.Second() );
}
示例6: LogDateTime
// ---------------------------------------------------------------------------
// TPresCondValidity::LogDateTime()
// ---------------------------------------------------------------------------
//
void TPresCondValidity::LogDateTime(TDateTime aDateTime)
{
OPENG_DP(D_OPENG_LIT( " %d, %d, %d, %d, %d, %d, %d"),
aDateTime.Year(), aDateTime.Month()+1, aDateTime.Day()+1,
aDateTime.Hour(), aDateTime.Minute(), aDateTime.Second(),
aDateTime.MicroSecond() );
}
示例7: WriteDateStamp
void CTestTransaction::WriteDateStamp(const TDateTime &aDate)
{
TDateTime date;
TTime now;
TBool iEOL = (aDate.Year() == K_OUTOFBOUNDS_YEAR);
if (iEOL)
{
now.HomeTime();
date = now.DateTime();
}
else
date = aDate;
TTime t(date);
TBuf<128> dateTimeString;
TRAPD(err, t.FormatL(dateTimeString, KDateFormat));
if (err == KErrNone)
{
if (iEOL)
Machine()->MsgPrintf(_L("[%S] "), &dateTimeString);
else
Log(_L("[%S]\r\n"), &dateTimeString);
}
}
示例8: TTimeIntervalSeconds
static struct tm& as_struct_tm (const time_t& t, struct tm& res)
{
TTime us = UNIX_BASE + TTimeIntervalSeconds(t);
TDateTime dt = us.DateTime();
res.tm_sec = dt.Second();
res.tm_min = dt.Minute();
res.tm_hour = dt.Hour();
res.tm_mday = dt.Day() + 1;
res.tm_mon = dt.Month();
res.tm_year = dt.Year() - 1900;
// EPOC32 counts the year day as Jan 1st == day 1
res.tm_yday = us.DayNoInYear() - 1;
// EPOC32 counts the weekdays from 0==Monday to 6==Sunday
res.tm_wday = us.DayNoInWeek() + 1;
if (res.tm_wday==7)
res.tm_wday=0; // Sunday==0 in a struct tm
// newlib just sets this field to -1
// tm_isdst doesn't really make sense here since we don't
// know the locale for which to interpret this time.
res.tm_isdst = -1;
return res;
}
示例9: doTestStepL
TVerdict CTestImpBDay::doTestStepL()
/**
* @return - TVerdict code
* Override of base class pure virtual
*/
{
SetTestStepResult(EFail);
TInt numberOfCases = 0;
while(ETrue)
{
TBuf<90> config(KImportBDay);
TPtrC ptrexpUTC = GetExpectedUTCFromIniL(numberOfCases, config, ETrue);
if(ptrexpUTC==KNullDesC)
{
break;
}
INFO_PRINTF2(_L("TEST: %d"), numberOfCases+1);
iExpectedBDay = FormatDateTime(ptrexpUTC);
TBuf<90> pathVCF(KPathImportBDay);
OpenBDAYVCFAndImportItemL(pathVCF, numberOfCases); // Imports vcf
TDateTime importedDateTime = iBDayFromImport.DateTime();
TDateTime expectedDateTime = iExpectedBDay.DateTime();
// If birthday does not match, test will fail
if((importedDateTime.Year() != expectedDateTime.Year()) ||
(importedDateTime.Month() != expectedDateTime.Month()) ||
(importedDateTime.Day() != expectedDateTime.Day()) )
{
INFO_PRINTF1(_L("Imported Birthday not correct"));
SetTestStepResult(EFail);
return TestStepResult();
}
else
{
INFO_PRINTF1(_L("Imported Birthday as expected"));
SetTestStepResult(EPass);
}
numberOfCases++;
}
return TestStepResult();
}
示例10: NumberOfEvents
// ----------------------------------------------------
// CAlfExCalendarEngine::NumberOfEvents
// ----------------------------------------------------
TInt CAlfExCalendarEngine::NumberOfEvents(const TTime& aDate)
{
TInt count = 0;
TDateTime requestedDate = aDate.DateTime();
const TInt arrayCount = iCalendarEventArray.Count();
for(TInt loop = 0; loop < arrayCount; loop++)
{
TDateTime eventDate = iCalendarEventArray[loop].iItemDay.DateTime();
if(eventDate.Day() == requestedDate.Day() &&
eventDate.Month() == requestedDate.Month() &&
eventDate.Year() == requestedDate.Year())
{
count++;
}
}
return count;
}
示例11: MakeTimeStrMilli
void TAzenqosEngineUtils::MakeTimeStrMilli(TTime &time,TDes& str) //str should be at least 19 in length
{
const TInt KThousand = 1000;
TDateTime date = time.DateTime();
str.Format(KTimeStampMillisecFormat,date.Year()%2000,date.Month()+1,date.Day()+1,date.Hour(),date.Minute(),date.Second(),date.MicroSecond()*KThousand);
}
示例12: EventsAvailable
// ----------------------------------------------------
// CAlfExCalendarEngine::EventsAvailable
// ----------------------------------------------------
TBool CAlfExCalendarEngine::EventsAvailable(const TTime& aDate)
{
TBool ret( EFalse );
TDateTime requestedDate = aDate.DateTime();
const TInt arrayCount = iCalendarEventArray.Count();
for(TInt loop = 0; loop < arrayCount; loop++)
{
TDateTime eventDate = iCalendarEventArray[loop].iItemDay.DateTime();
if(eventDate.Day() == requestedDate.Day() &&
eventDate.Month() == requestedDate.Month() &&
eventDate.Year() == requestedDate.Year())
{
ret = ETrue;
break;
}
}
return ret;
}
示例13: CheckImportedBDay
TBool CTestExBDayLocal::CheckImportedBDay()
{
TDateTime importedDateTime = iBDayFromImport.DateTime();
TDateTime exportedDateTime = iBDayLocal.DateTime();
//checks if exported and imported birthday macthes, which it should, otherwise test failed
if((importedDateTime.Year() != exportedDateTime.Year()) ||
(importedDateTime.Month() != exportedDateTime.Month()) ||
(importedDateTime.Day() != exportedDateTime.Day()) )
{
INFO_PRINTF1(_L("Export and Import of birthday does not match (incorrect)"));
return EFalse;
}
else
{
INFO_PRINTF1(_L("Export and Import of birthday macthes (correct)"));
return ETrue;
}
}
示例14: ActualiseRuleDefinitionsL
void CTzDbRuleSet::ActualiseRuleDefinitionsL(CVTzActualisedRules& aActualisedRules, const RArray<TTzRuleDefinition*>& aTzRuleDefinitions, const RArray<TTzRuleUse*>& aTzRuleUses, TInt aUtcOffset, const TDateTime& aStartDateTime, const TDateTime& aEndDateTime, const TVTzActualisedRule& aDefaultRule) const
{
TInt startYear = aStartDateTime.Year();
TInt endYear = (aActualisedRules.EndYear() < (TUint)aEndDateTime.Year()) ? aActualisedRules.EndYear() : aEndDateTime.Year();
TInt rulesAddedSoFar = 0;
TInt yearOfFirstRule = endYear;
TInt count = aTzRuleDefinitions.Count();
TInt oldOffset = 0; // Arbitrarily set to zero. Required to create TTzRule.
for (TInt i = 0; i < count; i++)
{
for (TInt year = (startYear > aTzRuleUses[i]->iFromYear) ? startYear : aTzRuleUses[i]->iFromYear ; (year <= endYear) && (year <= aTzRuleUses[i]->iUntilYear); year++)
{
TTzRule trule(
static_cast<TUint16>(startYear), static_cast<TUint16>(endYear),
static_cast<TUint16>(oldOffset), static_cast<TUint16>(aUtcOffset + aTzRuleDefinitions[i]->iStdTimeOffset),static_cast<TMonth>(aTzRuleDefinitions[i]->iMonth), static_cast<TTzRuleDay>(aTzRuleDefinitions[i]->iDayRule),
static_cast<TUint8>(aTzRuleDefinitions[i]->iDayOfMonth), static_cast<TUint8>(aTzRuleDefinitions[i]->iDayOfWeek),
static_cast<TTzTimeReference>(aTzRuleDefinitions[i]->iTimeReference), static_cast<TTzTimeReference>(aTzRuleDefinitions[i]->iTimeOfChange));
TVTzActualisedRule tActRule = trule.Actualise(year);
if ( (tActRule.iTimeOfChange < aEndDateTime) && (tActRule.iTimeOfChange >= aStartDateTime) )
{
aActualisedRules.AddRuleL(tActRule);
// record the year of the first rule added
if (rulesAddedSoFar == 0)
{
yearOfFirstRule = year;
}
rulesAddedSoFar++;
}
}
}
// In some cases we need to add a "default rule" to aRules. ("Default rule"
// means a rule with zero as DST offset and the start-time of the time-alignment
// as time-of-change). This default rule will be added if no rule exists for the
// first year of the time alignment.
if ( (rulesAddedSoFar == 0) || (yearOfFirstRule > startYear) )
{
aActualisedRules.AddRuleL(aDefaultRule);
}
}
示例15: DateTimeToChinese
//------------------------------------------------------
// Class: TChineseCalendar
// Function: DateTimeToChinese
// Arguments: TDateTime &
//
// Comments: Sets the date held in the given TDateTime
// class to the TChineseCalendar class
//
// Return: void
//------------------------------------------------------
EXPORT_C void TChineseCalendar::DateTimeToChinese(const TDateTime &aDT)
{
TArithmeticalDate gregDate;
TGregorianCalendar greg;
gregDate.iDay = aDT.Day() + KCalConvMonthOffsetByOne;
gregDate.iMonth = (TInt)aDT.Month() + KCalConvMonthOffsetByOne;
gregDate.iYear = aDT.Year();
iJulianDay = greg.GregToJulianDay(gregDate);
}