bool CJS_Value::ConvertToDate(CJS_Runtime* pRuntime, CJS_Date& date) const { if (!IsDateObject()) return false; v8::Local<v8::Value> mutable_value = m_pValue; date.Attach(mutable_value.As<v8::Date>()); return true; }
FX_BOOL CJS_Value::ConvertToDate(CJS_Date& date) const { if (IsDateObject()) { date.Attach(m_pValue); return TRUE; } return FALSE; }
FX_BOOL CJS_Value::ConvertToDate(CJS_Date& date) const { // if (GetType() == VT_date) // { // date = (double)(*this); // return TRUE; // } if (IsDateObject()) { date.Attach(m_pValue); return TRUE; } return FALSE; }
void util::printd(const std::wstring &cFormat2, CJS_Date jsDate, bool bXFAPicture, std::wstring &cPurpose) { std::wstring cFormat = cFormat2; if (bXFAPicture) { return ; //currently, it doesn't support XFAPicture. } int iIndex; for(iIndex = 0;iIndex<sizeof(fcTable)/sizeof(stru_TbConvert);iIndex++) { int iStart = 0; int iEnd; while((iEnd = cFormat.find(fcTable[iIndex].lpszJSMark, iStart)) != -1) { cFormat.replace(iEnd,FXSYS_wcslen(fcTable[iIndex].lpszJSMark), fcTable[iIndex].lpszCppMark); iStart = iEnd; } } int iYear,iMonth,iDay,iHour,iMin,iSec; iYear = jsDate.GetYear(); iMonth = jsDate.GetMonth(); iDay = jsDate.GetDay(); iHour = jsDate.GetHours(); iMin = jsDate.GetMinutes(); iSec = jsDate.GetSeconds(); struct tm time = {}; time.tm_year = iYear-1900; time.tm_mon = iMonth; time.tm_mday = iDay; time.tm_hour = iHour; time.tm_min = iMin; time.tm_sec = iSec; // COleDateTime cppTm(iYear,iMonth+1,iDay,iHour,iMin,iSec); //CString strFormat = cppTm.Format(cFormat.c_str()); struct stru_TbConvertAd { const FX_WCHAR* lpszJSMark; int iValue; }; stru_TbConvertAd cTableAd[] ={ { L"m", iMonth+1 }, { L"d", iDay }, { L"H", iHour }, { L"h", iHour>12?iHour-12:iHour }, { L"M", iMin }, { L"s", iSec }, }; //cFormat = strFormat.GetBuffer(strFormat.GetLength()+1); for(iIndex = 0;iIndex<sizeof(cTableAd)/sizeof(stru_TbConvertAd);iIndex++) { wchar_t tszValue[10]; //_itot(cTableAd[iIndex].iValue,tszValue,10); CFX_WideString sValue; sValue.Format(L"%d",cTableAd[iIndex].iValue); memcpy(tszValue, (wchar_t *)sValue.GetBuffer(sValue.GetLength()+1),sValue.GetLength()*sizeof(wchar_t)); //strFormat.Replace(cTableAd[iIndex].lpszJSMark,"%d"); //strFormat.Format(strFormat,cTableAd[iIndex].iValue); int iStart = 0; int iEnd; while((iEnd = cFormat.find(cTableAd[iIndex].lpszJSMark, iStart)) != -1) { if (iEnd > 0) { if (cFormat[iEnd-1] == L'%') { iStart = iEnd+1; continue; } } cFormat.replace(iEnd,FXSYS_wcslen(cTableAd[iIndex].lpszJSMark),tszValue); iStart = iEnd; } } CFX_WideString strFormat; wchar_t buf[64] = {}; strFormat = wcsftime(buf, 64, cFormat.c_str(), &time); cFormat = buf; cPurpose = cFormat; }
CJS_Value::CJS_Value(CJS_Runtime* pRuntime, const CJS_Date& date) : m_pValue(date.ToV8Date(pRuntime)) {}