本文整理汇总了C++中VTime类的典型用法代码示例。如果您正苦于以下问题:C++ VTime类的具体用法?C++ VTime怎么用?C++ VTime使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了VTime类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: GetTime
void VJSONValue::GetTime(VTime& outTime) const
{
VError err = VE_OK;
switch (fType)
{
case JSON_string:
{
VString s;
s.FromString(fString);
outTime.FromString(s);
break;
}
case JSON_date:
{
outTime.FromMilliseconds(fTimeStamp);
break;
}
case JSON_number:
{
outTime.FromMilliseconds(fNumber);
break;
}
default:
{
outTime.Clear();
outTime.SetNull(true);
break;
}
}
}
开发者ID:StephaneH,项目名称:core-XToolbox,代码行数:34,代码来源:VJSONValue.cpp
示例2: JSObjectGetProperty
bool JS4D::DateObjectToVTime( ContextRef inContext, ObjectRef inObject, VTime& outTime, ExceptionRef *outException)
{
// it's caller responsibility to check inObject is really a Date using ValueIsInstanceOf
// call getTime()
bool ok = false;
JSStringRef jsString = JSStringCreateWithUTF8CString( "getTime");
JSValueRef getTime = JSObjectGetProperty( inContext, inObject, jsString, outException);
JSObjectRef getTimeFunction = JSValueToObject( inContext, getTime, outException);
JSStringRelease( jsString);
JSValueRef result = (getTime != NULL) ? JSObjectCallAsFunction( inContext, getTimeFunction, inObject, 0, NULL, outException) : NULL;
if (result != NULL)
{
// The getTime() method returns the number of milliseconds since midnight of January 1, 1970.
double r = JSValueToNumber( inContext, result, outException);
sLONG8 n = (sLONG8) r;
if (n == r)
{
outTime.FromUTCTime( 1970, 1, 1, 0, 0, 0, 0);
outTime.AddMilliseconds( n);
ok = true;
}
else
{
outTime.SetNull( true);
}
}
else
{
outTime.SetNull( true);
}
return ok;
}
开发者ID:sanyaade-webdev,项目名称:core-XToolbox,代码行数:33,代码来源:JS4D.cpp
示例3: JSValueMakeNumber
JS4D::ObjectRef JS4D::VTimeToObject( ContextRef inContext, const VTime& inTime, ExceptionRef *outException)
{
if (inTime.IsNull())
return NULL; // can't return JSValueMakeNull as an object
sWORD year, month, day, hour, minute, second, millisecond;
inTime.GetLocalTime( year, month, day, hour, minute, second, millisecond);
JSValueRef args[6];
args[0] = JSValueMakeNumber( inContext, year);
args[1] = JSValueMakeNumber( inContext, month-1);
args[2] = JSValueMakeNumber( inContext, day);
args[3] = JSValueMakeNumber( inContext, hour);
args[4] = JSValueMakeNumber( inContext, minute);
args[5] = JSValueMakeNumber( inContext, second);
#if NEW_WEBKIT
JSObjectRef date = JSObjectMakeDate( inContext, 6, args, outException);
#else
JSStringRef jsClassName = JSStringCreateWithUTF8CString("Date");
JSObjectRef constructor = JSValueToObject( inContext, JSObjectGetProperty( inContext, JSContextGetGlobalObject( inContext), jsClassName, NULL), NULL);
JSStringRelease( jsClassName);
JSObjectRef date = JSObjectCallAsConstructor( inContext, constructor, 6, args, outException);
#endif
return date;
}
开发者ID:sanyaade-webdev,项目名称:core-XToolbox,代码行数:28,代码来源:JS4D.cpp
示例4: do_isoToDate
void VJSGlobalClass::do_isoToDate(VJSParms_callStaticFunction& ioParms, VJSGlobalObject*)
{
VTime dd;
VString s;
ioParms.GetStringParam(1, s);
dd.FromJSONString(s);
ioParms.ReturnTime(dd);
}
开发者ID:sanyaade-webdev,项目名称:core-XToolbox,代码行数:8,代码来源:VJSGlobalClass.cpp
示例5: SetTime
void VJSONValue::SetTime(const VTime& inTime)
{
_Dispose();
if (inTime.IsNull())
fType = JSON_null;
else
{
fType = JSON_date;
fTimeStamp = inTime.GetMilliseconds();
}
}
开发者ID:StephaneH,项目名称:core-XToolbox,代码行数:11,代码来源:VJSONValue.cpp
示例6: jsval
void VJSGlobalClass::do_dateToIso(VJSParms_callStaticFunction& ioParms, VJSGlobalObject*)
{
VString s;
VJSValue jsval(ioParms.GetContextRef());
if (ioParms.CountParams() > 0)
{
VTime dd;
jsval = ioParms.GetParamValue(1);
jsval.GetTime(dd);
dd.GetJSONString(s);
}
ioParms.ReturnString(s);
}
开发者ID:sanyaade-webdev,项目名称:core-XToolbox,代码行数:13,代码来源:VJSGlobalClass.cpp
示例7: IsIncludedFilesHaveBeenChanged
bool VJSGlobalObject::IsIncludedFilesHaveBeenChanged() const
{
bool haveChanges = false;
for (VectorOfFileModificationTime::const_iterator iter = fIncludedFilesModificationTime.begin() ; (iter != fIncludedFilesModificationTime.end()) && !haveChanges ; ++iter)
{
if (iter->first != NULL)
{
VTime modificationTime;
iter->first->GetTimeAttributes( &modificationTime);
haveChanges = (modificationTime.CompareTo( iter->second) != CR_EQUAL);
}
}
return haveChanges;
}
开发者ID:sanyaade-webdev,项目名称:core-XToolbox,代码行数:15,代码来源:VJSGlobalClass.cpp
示例8: ClothoEvent
ShellMaturityEvent::ShellMaturityEvent( const VTime & tSend, const VTime & tRecv,
const ObjectID &sender,
const ObjectID & receiver,
const EventId & evtID,
const VTime & tMature ) :
ClothoEvent( tSend, tRecv, sender, receiver, evtID ),
m_age_of_maturity( tMature.clone() ) {}
开发者ID:putnampp,项目名称:clotho-dev,代码行数:7,代码来源:ShellMaturityEvent.cpp
示例9: fossilCollect
void ThreadedOptFossilCollManager::fossilCollect(SimulationObject *object,
const VTime ¤tTime, const unsigned int &threadId) {
unsigned int objId = object->getObjectID()->getSimulationObjectID();
fossilPeriod[objId]++;
if (fossilPeriod[objId] >= 20) {
int intCurTime = currentTime.getApproximateIntTime();
if (intCurTime > activeHistoryLength[objId]) {
int collectTime = intCurTime - activeHistoryLength[objId];
if (collectTime > lastCollectTimes[objId]) {
lastCollectTimes[objId] = collectTime;
cout << "Fossil Collecting " << collectTime << endl;
mySimManager->getStateManagerNew()->fossilCollect(object,
collectTime, threadId);
mySimManager->getOutputManagerNew()->fossilCollect(object,
collectTime, threadId);
mySimManager->getEventSetManagerNew()->fossilCollect(object,
collectTime, threadId);
/*
utils::debug << "Fossil Collecting Obj " << objId
<< " at time " << collectTime << " now at " << intCurTime << endl;
*/
}
}
fossilPeriod[objId] = 0;
}
mySimManager->setCheckpointing(false);
}
开发者ID:putnampp,项目名称:pdes,代码行数:27,代码来源:ThreadedOptFossilCollManager.cpp
示例10: AddTimestamp
// добавление таймштампа
bool VSQLGenerator::AddTimestamp(const std::string & name, const VTime & value)
{
if (this->NameExists(name)) return false;
// this->prm_names.push_back(name);
// struct tm __t = value.ToTM();
// this->prm_bodies.push_back(VIBParameter(SQL_TIMESTAMP, (const char*)&__t));
if (InlineSQL)
{
this->AddString(name, value.DateToStringISO());
}
else
{
struct tm __t = value.ToTM();
this->AddParameter(name, VIBParameter(SQL_TIMESTAMP, (const char*)&__t));
}
return true;
}
开发者ID:imzhukov,项目名称:video_3.0.0,代码行数:20,代码来源:sqlgen.cpp
示例11: FormatTime
void XWinIntlMgr::FormatTime( const VTime& inTime, VString& outTime, EOSFormats inFormat, bool inUseGMTTimeZoneForDisplay)
{
// 1:system short time; 2:system medium time; 3:system long time
DWORD timeFormat=0;
switch(inFormat)
{
case eOS_SHORT_FORMAT:// No signs
case eOS_MEDIUM_FORMAT:// No signs
timeFormat=TIME_NOTIMEMARKER;
break;
case eOS_LONG_FORMAT://all
break;
default:
break;
};
// Prepare SYSTEMTIME for windows.
sWORD YY=0,MM=0,DD=0,hh=0,mm=0,ss=0,ms=0;
SYSTEMTIME osTime={0};
if (inUseGMTTimeZoneForDisplay)
inTime.GetUTCTime (YY,MM,DD,hh,mm,ss,ms);
else
inTime.GetLocalTime (YY,MM,DD,hh,mm,ss,ms);
osTime.wYear=YY;
osTime.wMonth=MM;
osTime.wDay=DD;
osTime.wHour=hh;
osTime.wMinute=mm;
osTime.wSecond=ss;
osTime.wMilliseconds=ms;
// Let the OS do the stuff.
UniChar acBuffer[256];
if (::GetTimeFormatW( fDialect,timeFormat,&osTime,NULL,acBuffer,sizeof(acBuffer)))
outTime=acBuffer;
else
outTime.Clear();
}
开发者ID:sanyaade-iot,项目名称:core-XToolbox,代码行数:39,代码来源:XWinIntlMgr.cpp
示例12: JSValueToObject
bool VJSValue::GetTime( VTime& outTime, JS4D::ExceptionRef *outException) const
{
bool ok;
if (JS4D::ValueIsInstanceOf( fContext, fValue, CVSTR( "Date"), outException))
{
JSObjectRef dateObject = JSValueToObject( fContext, fValue, outException);
ok = JS4D::DateObjectToVTime( fContext, dateObject, outTime, outException, false);
}
else
{
outTime.SetNull( true);
ok = false;
}
return ok;
}
开发者ID:sanyaade-iot,项目名称:core-XToolbox,代码行数:15,代码来源:VJSValue.cpp
示例13: VTimeToGregorianCalendar
//static
icu::GregorianCalendar XLinuxIntlMgr::VTimeToGregorianCalendar(const VTime& inDate)
{
//VTime is in GMT time zone
icu::TimeZone* gmt=TimeZone::getGMT()->clone();
UErrorCode err=U_ZERO_ERROR;
GregorianCalendar cal(gmt, err); //cal owns gmt and should destroy it
xbox_assert(err==U_ZERO_ERROR);
sWORD year, month, day, hour, minute, second, millisecond;
inDate.GetUTCTime(year, month, day, hour, minute, second, millisecond);
cal.set(year, month, day, hour, minute, second);
return cal;
}
开发者ID:sanyaade-mobiledev,项目名称:core-XToolbox,代码行数:17,代码来源:XLinuxIntlMgr.cpp
示例14: testMySQLConnectorPreparedStatementWithDateParam
void testMySQLConnectorPreparedStatementWithDateParam()
{
CSQLConnector* connector = (CSQLConnector*) ( VComponentManager::RetainComponent ( 'MYSQ', 'SQL ' ) );
VJSONObject* params = new VJSONObject();
params->SetProperty ( "hostname", MYSQL_HOST );
params->SetProperty ( "user", MYSQL_USER );
params->SetProperty ( "password", MYSQL_CORRECT_PASSWORD );
params->SetProperty ( "database", MYSQL_DATABASE );
params->SetProperty ( "port", MYSQL_PORT );
params->SetProperty ( "ssl", MYSQL_SSL_FALSE );
ISQLSession* session = connector->CreateSession ( params );
ReleaseRefCountable ( ¶ms );
if ( session != NULL )
{
ISQLStatement* statement = session->CreateStatement ( "SELECT * FROM people WHERE date_of_birth = ?" );
VError error = VE_OK;
ISQLPreparedStatement* pStmt = statement->CreatePreparedStatement ( error );
VTime keyDate;
keyDate.FromUTCTime ( 1984, 8, 11, 0, 0, 0, 0 );
pStmt->SetNthParameter ( 1, keyDate );
ISQLResultSet* res = pStmt->Execute ( error );
if ( error == VE_OK )
{
if ( res->IsError() )
{
printf ( "an error occured in the execution of the prepared statement!\n" );
VString msg = res->GetErrorMessage();
printf ( "error msg = %V\n", &msg );
}
else
{
while ( !res->IsEOF() )
{
ISQLRow* row = res->RetainNextRow();
VValue* idValue = row->GetNthValue ( 1 );
VValue* firstNameValue = row->GetNthValue ( 3 );
VValue* dateValue = row->GetNthValue ( 5 );
VString DbgMsg;
DbgMsg.AppendPrintf ( "idValue = %V, firstNameValue = %V, dateValue = %V", idValue, firstNameValue, dateValue );
DebugMsg ( "%V", &DbgMsg );
ReleaseRefCountable ( &row );
}
}
ReleaseRefCountable ( &res );
}
else
{
printf ( "an error occured in the execution of the prepared statement!\n" );
}
ReleaseRefCountable ( &session );
}
else
{
printf ( "connection to mysql server failed ..\n" );
}
ReleaseRefCountable ( &connector );
}
开发者ID:StephaneH,项目名称:core-Wakanda,代码行数:87,代码来源:testMySQLConnector.cpp
示例15: FormatDate
void XWinIntlMgr::FormatDate( const VTime& inDate, VString& outDate, EOSFormats inFormat, bool inUseGMTTimeZoneForDisplay)
{
// Prepare SYSTEMTIME for windows.
sWORD YY = 0;
sWORD MM = 0;
sWORD DD = 0;
sWORD hh = 0;
sWORD mm = 0;
sWORD ss = 0;
sWORD ms = 0;
if (inUseGMTTimeZoneForDisplay)
inDate.GetUTCTime (YY,MM,DD,hh,mm,ss,ms);
else
inDate.GetLocalTime (YY,MM,DD,hh,mm,ss,ms);
// Verify if date >1st Jan 1601 (GetDateFormat doesn't support earlier dates.
if (YY>=1601)
{
// Let the OS do it's job.
UniChar acBuffer[256];
SYSTEMTIME osDate={0};
osDate.wYear=YY;
osDate.wMonth=MM;
osDate.wDay=DD;
osDate.wHour=hh;
osDate.wMinute=mm;
osDate.wSecond=ss;
osDate.wMilliseconds=ms;
if (inFormat == eOS_MEDIUM_FORMAT)
{
VString pattern;
if (GetLocaleInfo( LOCALE_SLONGDATE, pattern))
{
// replace long month and date by medium ones
pattern.ExchangeRawString( CVSTR( "MMMM"), CVSTR( "MMM"));
pattern.ExchangeRawString( CVSTR( "dddd"), CVSTR( "ddd"));
if (::GetDateFormatW( fDialect, 0, &osDate, pattern.GetCPointer(), acBuffer, sizeof(acBuffer)))
outDate = acBuffer;
}
}
else
{
// Let the OS do the stuff.
DWORD dateFormat = (inFormat == eOS_SHORT_FORMAT) ? DATE_SHORTDATE : DATE_LONGDATE;
if (::GetDateFormatW(fDialect,dateFormat,&osDate,NULL,acBuffer,sizeof(acBuffer)))
outDate = acBuffer;
}
}
else
{
// Get the date pattern
VString pattern;
if (GetLocaleInfo( (inFormat == eOS_LONG_FORMAT) ? LOCALE_SLONGDATE : LOCALE_SSHORTDATE, pattern))
{
XBOX::VString tokens="gyMd";
UniChar oldToken=0;
sLONG count=0;
pattern.AppendChar(' ');
sLONG YY2=YY%100;
XBOX::VString oneName;
for (int pos=0;pos<pattern.GetLength();pos++)
{
UniChar token=pattern[pos];
if (tokens.FindUniChar(token)>=1)
{
if (token==oldToken)
count++;
else
{
if (!count)
{
count=1;
oldToken=token;
}
}
}
if (count && token!=oldToken)
{
switch(oldToken)
{
case 'g':
if (count==2)
{
// TODO: ERA will be added if really wanted.
}
else
{
for (int i=0;i<count;i++)
outDate.AppendUniChar(oldToken);
}
break;
case 'y': // YEAR
switch(count)
{
case 5:
case 4: // 4 or more digits date
//.........这里部分代码省略.........
开发者ID:sanyaade-iot,项目名称:core-XToolbox,代码行数:101,代码来源:XWinIntlMgr.cpp
示例16: getOfcChebyLock
void
ThreadedChebyFossilCollManager::sampleRollback(SimulationObject* object, const VTime& rollVTime) {
int rollbackTime = rollVTime.getApproximateIntTime();
int rollbackDistance = object->getSimulationTime().getApproximateIntTime() - rollbackTime;
unsigned int objId = object->getObjectID()->getSimulationObjectID();
int threadId = *((int*) pthread_getspecific(threadKey));
getOfcChebyLock(threadId,mySimManager->getSyncMechanism());
if (numSamples[objId] < maxSamples) {
// Sample the rollback.
total[objId] = total[objId] - samples[objId][sampleIndex[objId]];
samples[objId][sampleIndex[objId]] = rollbackDistance;
total[objId] = total[objId] + rollbackDistance;
sampleIndex[objId]++;
numSamples[objId]++;
// If there are enough samples, then calculate the mean, variance
// and new active history length.
if (numSamples[objId] > minSamples) {
double sampleVariance = 0;
double mean1, mean2;
double variance1, variance2;
mean1 = mean2 = variance1 = variance2 = 0;
double sampleMean = total[objId] / double(numSamples[objId]);
for (int i = 0; i < numSamples[objId]; i++) {
sampleVariance += ((double(samples[objId][i]) - sampleMean) *
(double(samples[objId][i]) - sampleMean));
}
sampleVariance = sampleVariance / numSamples[objId];
mean1 = sampleMean - 1.96*sqrt(sampleVariance/(double)numSamples[objId]);
mean2 = sampleMean + 1.96*sqrt(sampleVariance/(double)numSamples[objId]);
for (int i = 0; i < numSamples[objId]; i++) {
variance1 += ((double(samples[objId][i]) - mean1) *
(double(samples[objId][i]) - mean1));
variance2 += ((double(samples[objId][i]) - mean2) *
(double(samples[objId][i]) - mean2));
}
variance1 = variance1 / numSamples[objId];
variance2 = variance2 / numSamples[objId];
if (variance1 < variance2) {
sampleVariance = variance2;
} else {
sampleVariance = variance1;
}
activeHistoryLength[objId] = sampleMean + errorTerm * sqrt(sampleVariance/(1.0-riskFactor));
debug::debugout << objId << " - NEW LENGTH: " << activeHistoryLength[objId] << endl;
}
}
if (lastCollectTimes[objId] >= 0 && !recovering && rollbackTime <= lastCollectTimes[objId]) {
debug::debugout << mySimManager->getSimulationManagerID()
<< " - Catastrophic Rollback: Last collection time: " << lastCollectTimes[objId]
<< ", Rollback Time: " << rollbackTime << ", Starting Recovery." << endl;
setRecovery(objId, rollbackTime);
}
releaseOfcChebyLock(threadId,mySimManager->getSyncMechanism());
}
开发者ID:wilseypa,项目名称:warped,代码行数:68,代码来源:ThreadedChebyFossilCollManager.cpp
示例17: rollback
void ThreadedTimeWarpMultiSet::rollback(SimulationObject* simObj,
const VTime& rollbackTime, int threadId) {
// Go through the entire processed events queue and put any events with
// a receive time greater than or equal to the rollback time back in the
// unprocessed queue.
unsigned int objId = simObj->getObjectID()->getSimulationObjectID();
this->getProcessedLock(threadId, objId);
vectorIterator[threadId] = processedQueue[objId]->begin();
int tempCount = 0;
if (rollbackTime.getApproximateIntTime() == 0) {
tempCount = processedQueue[objId]->size();
} else {
vectorIterator[threadId] = processedQueue[objId]->begin();
while (vectorIterator[threadId] != processedQueue[objId]->end()
&& (*(vectorIterator[threadId]))->getReceiveTime()
< rollbackTime) {
(vectorIterator[threadId])++;
tempCount++;
}
const unsigned int
eventIdRollback =
mySimulationManager->getStateManagerNew()->getEventIdForRollback(
threadId, objId);
const unsigned int
senderObjectId =
mySimulationManager->getStateManagerNew()->getSenderObjectIdForRollback(
threadId, objId);
const unsigned int
senderObjectSimId =
mySimulationManager->getStateManagerNew()->getSenderObjectSimIdForRollback(
threadId, objId);
// cout << "The saved EventId is --------------------->>>>>>>>>>>> : "
// << eventIdRollback << endl;
// cout << "The First EventId is --------------------->>>>>>>>>>>> : "
// << (*(vectorIterator[threadId]))->getEventId() << endl;
// cout << "The saved SenderObjectId is --------------------->>>>>>>>>>>> : "
// << senderObjectId << endl;
while (vectorIterator[threadId] != processedQueue[objId]->end()) {
EventId tempEventId = (*(vectorIterator[threadId]))->getEventId();
unsigned int
tempSenderObjectId =
(*(vectorIterator[threadId]))->getSender().getSimulationObjectID();
if (tempEventId.getEventNum() != eventIdRollback
|| tempSenderObjectId != senderObjectId) {
/*cout << "Skipping Event.......::::::::::::: "
<< **(vectorIterator[threadId]) << endl;*/
(vectorIterator[threadId])++;
tempCount++;
} else {
/* cout << " Matched EventId ::::" << **(vectorIterator[threadId])
<< endl;*/
break;
}
}
tempCount = processedQueue[objId]->size() - tempCount;
}
debug::debugout << "( " << mySimulationManager->getSimulationManagerID()
<< " ) Object - " << objId << " Rollback returns : " << tempCount
<< " events back to Unprocessed Queue - " << threadId << endl;
unProcessedQueue[objId]->insert(vectorIterator[threadId],
processedQueue[objId]->end());
processedQueue[objId]->erase(vectorIterator[threadId],
processedQueue[objId]->end());
this->releaseProcessedLock(threadId, objId);
// Increment number of rolled back events
//cout << "rollback completed " << tempCount << " events rolled back, LTSF " << LTSFObjId[objId][LTSFOWNER] << endl;
__sync_fetch_and_add(&(rolledBackEventsByObj[objId]), tempCount);
__sync_fetch_and_add(&(rolledBackEventsByLTSF[ LTSFObjId[objId][LTSFOWNER] ]), tempCount);
// Perform calculation to see if a load balance 'action' is necessary
// Load balancing function is performed using the currently running thread
if (lbType) {
myLoadBalancer->balanceCheck();
}
}
开发者ID:wilseypa,项目名称:warped,代码行数:77,代码来源:ThreadedTimeWarpMultiSet.cpp
示例18: setGVT
void GVTManagerImplementationBase::setGVT( const VTime &newGVT ){
//It is possible some thread is using gVT so it cant be deleted here
//for the threadedTimeWarp Version
//delete gVT;
gVT = newGVT.clone();
}
开发者ID:CindyYang85,项目名称:pdes,代码行数:6,代码来源:GVTManagerImplementationBase.cpp
示例19:
void
DefaultSchedulingManager::setLastScheduledEventTime( const VTime &newTime ) {
delete lastScheduledTime;
lastScheduledTime = newTime.clone();
}
开发者ID:joerocklin,项目名称:pdes,代码行数:5,代码来源:DefaultSchedulingManager.cpp
示例20: fType
VJSONValue::VJSONValue(const VTime& inTime)
: fType(inTime.IsNull() ? JSON_null : JSON_date)
{
if (fType == JSON_date)
fTimeStamp = inTime.GetMilliseconds();
}
开发者ID:StephaneH,项目名称:core-XToolbox,代码行数:6,代码来源:VJSONValue.cpp
注:本文中的VTime类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论