SunTimeResult SunTimes::GetSunTime(QDateTime date, double latitude , double longitude ) { double start = 0; double end = 0; SunRiset(date.date().year(), date.date().month(), date.date().day(), longitude, latitude, -35.0 / 60.0, 1, start, end); QDateTime sunrise = ToLocalTime(date, start); QDateTime sunset = ToLocalTime(date, end); SunTimeResult *sunTimeResult = new SunTimeResult(sunrise, sunset); return *sunTimeResult; }
void BufferTimeList::Monitor() { vector<TCHAR *> messages; try { AutoLock lock(&_sync); for (int idx = 0; idx < _files.size(); idx++) { FILETIME time; if (IsChanged(_files[idx]->BufferId, &time)) { TCHAR localTime[256]; ToLocalTime(time, localTime); TCHAR *pbuffer = new TCHAR[1024]; generic_sprintf(pbuffer, TEXT("\"%s\" has been modified by another program (%s)."), _files[idx]->Path, localTime); messages.push_back(pbuffer); } } } catch (...) { // ignore all }; // flash outside of the lock as otherwise it will block messgages which in-turn causes deadlock if (messages.size() > 0) FlashCaption(messages); }
void BufferTimeList::BeforeSave(unsigned long bufferId) { AutoLock lock(&_sync); FILETIME time; if (!IsChanged(bufferId, &time)) return; BufferTime *pFile = Find(bufferId); SendMessage(_hwnd, WM_COMMAND, IDM_EDIT_SELECTALL, 0); SendMessage(_hwnd, WM_COMMAND, IDM_EDIT_COPY, 0); SendMessage(_hwnd, WM_COMMAND, IDM_EDIT_DELETE, 0); SendMessage(_hwnd, NPPM_RELOADFILE, 0, (LPARAM) pFile->Path); // 0 - no alert SendMessage(_hwnd, WM_COMMAND, IDM_FILE_NEW, 0); SendMessage(_hwnd, WM_COMMAND, IDM_EDIT_PASTE, 0); TCHAR localTime[256]; ToLocalTime(time, localTime); TCHAR newTitle[256]; SendMessage(_hwnd, NPPM_GETFULLCURRENTPATH, 256, (LPARAM) newTitle); TCHAR buffer[1024]; static const TCHAR * format = TEXT("Your changes have NOT been saved because \"%s\" was modified and saved to disk by another program (%s).\n\nThe file has now been reloaded and your changes have been copied to the \"%s\" tab."); generic_sprintf(buffer, format, pFile->Path, localTime, newTitle); ErrorBox(_hwnd, buffer); }