当前位置: 首页>>代码示例>>C++>>正文


C++ TLocale::UniversalTimeOffset方法代码示例

本文整理汇总了C++中TLocale::UniversalTimeOffset方法的典型用法代码示例。如果您正苦于以下问题:C++ TLocale::UniversalTimeOffset方法的具体用法?C++ TLocale::UniversalTimeOffset怎么用?C++ TLocale::UniversalTimeOffset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TLocale的用法示例。


在下文中一共展示了TLocale::UniversalTimeOffset方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: toLocal

/*
Intended Usage:	Utility routine for converting from UTC to localtime.
*/
inline time_t toLocal (const time_t aUniversalTime)
{
#ifndef __SERIES60_MRT_1_0
    TTimeIntervalSeconds offset = User::UTCOffset();
    return aUniversalTime + offset.Int();
#else
    TLocale locale;
    return aUniversalTime + locale.UniversalTimeOffset().Int();
#endif //__SERIES60_MRT_1_0
}
开发者ID:kuailexs,项目名称:symbiandump-os2,代码行数:13,代码来源:time.cpp

示例2: ConvertToLocal

// ---------------------------------------------------------------------------
// TPresCondValidity::ConvertToLocal()
// ---------------------------------------------------------------------------
//        
void TPresCondValidity::ConvertToLocal(TTime& aDateTime)
    {
    OPENG_DP(D_OPENG_LIT( " TPresCondValidity::ConvertToLocal()" ) );
    OPENG_DP(D_OPENG_LIT( "     ConvertToLocal aDateTime:"));
    LogDateTime(aDateTime.DateTime());

    TLocale myLocale;
    myLocale.Refresh();
    
    // getting UTC difference    
    TTimeIntervalSeconds uTCseconds = myLocale.UniversalTimeOffset();
    aDateTime = aDateTime + uTCseconds;
    }
开发者ID:cdaffara,项目名称:symbiandump-mw2,代码行数:17,代码来源:prescondvalidity.cpp

示例3: GetDatePacked

bool_t GetDatePacked(datetime_t t, datepack_t *tp, bool_t Local)
{
	TDateTime Date;
    TTime ot;
	if (!tp || t == INVALID_DATETIME_T) return 0;
	
    ot = DateTimeToSymbian(t);

    if (Local) 
    {
#ifndef SYMBIAN90
        TLocale locale;
        TTimeIntervalSeconds universalTimeOffset(locale.UniversalTimeOffset());
        ot += universalTimeOffset;
        if (locale.QueryHomeHasDaylightSavingOn())
        {
            TTimeIntervalHours daylightSaving(1);
            ot += daylightSaving;
        }
#else
        RTz TzServer;
        if (TzServer.Connect()==KErrNone)
        {
            CTzConverter* Converter = CTzConverter::NewL(TzServer); 
            Converter->ConvertToLocalTime(ot);
            delete Converter;
            TzServer.Close();
        }
#endif
    }

	Date = ot.DateTime();
	tp->Year = Date.Year();
	tp->Month = (int)Date.Month() + 1;
	tp->Day = Date.Day()+1;
	tp->Hour = Date.Hour();
	tp->Minute = Date.Minute();
	tp->Second = Date.Second();
	return 1;
}
开发者ID:ViFork,项目名称:ResInfo,代码行数:40,代码来源:date_symbian.cpp

示例4: TimePackToRel

datetime_t TimePackToRel(const datepack_t *tp, bool_t Local)
{
    TDateTime Date;
    TTime ot;
	if (!tp) return INVALID_DATETIME_T;
    Date.SetYear(tp->Year);
    Date.SetMonth((TMonth)(tp->Month-1));
    Date.SetDay(tp->Day-1);
    Date.SetHour(tp->Hour);
    Date.SetMinute(tp->Minute);
    Date.SetSecond(tp->Second);

    ot = TTime(Date);

    if (Local) 
    {
#ifndef SYMBIAN90
        TLocale locale;
        TTimeIntervalSeconds universalTimeOffset(locale.UniversalTimeOffset());
        ot -= universalTimeOffset;
        if (locale.QueryHomeHasDaylightSavingOn())
        {
            TTimeIntervalHours daylightSaving(1);
            ot -= daylightSaving;
        }
#else
        RTz TzServer;
        if (TzServer.Connect()==KErrNone)
        {
            CTzConverter* Converter = CTzConverter::NewL(TzServer); 
            Converter->ConvertToUniversalTime(ot);
            delete Converter;
            TzServer.Close();
        }
#endif
    }

    return SymbianToDateTime(ot);
}
开发者ID:ViFork,项目名称:ResInfo,代码行数:39,代码来源:date_symbian.cpp

示例5: DoLog

void DoLog(const TDesC& aText)
{
    static const TInt KLogEntryMaxLength = 128;
    _LIT(KLineFeed, "\n");



    /**
     *  Log time format (see TTime) is
     *  Day-Month-Year Hours:Minutes:Seconds:Milliseconds
     *
     *  Example: 30-12-2004 23:00:55:990
     */
    _LIT(KLogTimeFormat, "%F%D-%M-%Y %H:%T:%S:%*C3");

    TBuf8<KLogEntryMaxLength> writeBuffer;
    RFs FileServer;
    RFile File;

    if(FileServer.Connect() != KErrNone)
    {
        FileServer.Close(); // just in case
        User::Panic(KLogPanicCategory(), KPanicFsConnectFailed);
        return;
    }

    // Open file for writing, if exists. Othervise create new file.
    if(File.Open(FileServer, KLogFileName(), EFileWrite) != KErrNone)
    {
        if(File.Create(FileServer, KLogFileName(), EFileWrite) != KErrNone)
        {
            FileServer.Close();
            User::Panic(KLogPanicCategory(), KPanicFileCreateFailed);
        }
    }

    TTime currentTime;
    currentTime.UniversalTime();
    TBuf<32> timeString;

    // currentTime is now in universal time. Convert it to home time.
    TLocale locale;
    TTimeIntervalSeconds universalTimeOffset(locale.UniversalTimeOffset());
    TTimeIntervalHours daylightSaving(0);
    if(locale.QueryHomeHasDaylightSavingOn())
    {
        daylightSaving = 1;
    }
    currentTime = currentTime + universalTimeOffset + daylightSaving;
    TInt leaveCode(KErrNone);
    TRAP(leaveCode, currentTime.FormatL(timeString, KLogTimeFormat));
    leaveCode = 0; // not used
    // Add LogString to the end of file and close the file
    TInt currentSize = 0, returnCode;
    writeBuffer.Append(timeString);
    writeBuffer.Append(_L(": "));
    writeBuffer.Append(aText.Left(KLogEntryMaxLength-timeString.Length()));
    writeBuffer.Append(KLineFeed);
    File.Size(currentSize);
    returnCode = File.Write(currentSize,
                            writeBuffer,
                            writeBuffer.Length());
    File.Close();
    // Close file server session
    FileServer.Close();

    if(returnCode != KErrNone)
    {
        User::Panic(KLogPanicCategory(), KPanicFileWriteFailed);
    }
}
开发者ID:kuailexs,项目名称:symbiandump-mw4,代码行数:71,代码来源:logger.cpp


注:本文中的TLocale::UniversalTimeOffset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。