コード例 #1
0
ファイル: datectrl.cpp プロジェクト: nE0sIghT/wxWidgets
void wxDatePickerCtrl::SetRange(const wxDateTime& dt1, const wxDateTime& dt2)
{
    SYSTEMTIME st[2];

    DWORD flags = 0;
    if ( dt1.IsValid() )
    {
        dt1.GetAsMSWSysTime(st + 0);
        flags |= GDTR_MIN;
    }

    if ( dt2.IsValid() )
    {
        dt2.GetAsMSWSysTime(st + 1);
        flags |= GDTR_MAX;
    }

    if ( !DateTime_SetRange(GetHwnd(), flags, st) )
    {
        wxLogDebug(wxT("DateTime_SetRange() failed"));
        return;
    }

    // Setting the range could have changed the current control value if the
    // old one wasn't inside the new range, so update it.
    m_date = MSWGetControlValue();
}
コード例 #2
0
ファイル: misc.cpp プロジェクト: swflb/pgadmin3
wxString DateToStr(const wxDateTime &datetime)
{
	if (!datetime.IsValid())
		return wxEmptyString;

	return datetime.FormatDate() + wxT(" ") + datetime.FormatTime();
}
コード例 #3
0
ファイル: timectrlg.cpp プロジェクト: jfiguinha/Regards
    // Set the current field to its minimal or maximal value.
    void ResetCurrentField(Direction dir)
    {
        switch ( m_currentField )
        {
            case Field_Hour:
            case Field_AMPM:
                // In 12-hour mode setting the hour to the minimal value
                // also changes the suffix to AM and, correspondingly,
                // setting it to the maximal one changes the suffix to PM.
                // And, for consistency with the native MSW behaviour, we
                // also do the same thing when changing AM/PM field itself,
                // so change hours in any case.
                m_time.SetHour(dir == Dir_Down ? 0 : 23);
                break;

            case Field_Min:
                m_time.SetMinute(dir == Dir_Down ? 0 : 59);
                break;

            case Field_Sec:
                m_time.SetSecond(dir == Dir_Down ? 0 : 59);
                break;

            case Field_Max:
                wxFAIL_MSG( "Invalid field" );
                return;
        }

        UpdateText();
    }
コード例 #4
0
ファイル: wxe_return.cpp プロジェクト: AlainODea/otp
INLINE 
void  wxeReturn::addDate(wxDateTime dateTime) {
    addInt(dateTime.GetYear());
    addInt(dateTime.GetMonth()+1); // c++ month is zero based
    addInt(dateTime.GetDay());
    addTupleCount(3);
}
コード例 #5
0
ファイル: updater.cpp プロジェクト: juaristi/filezilla
bool CUpdater::Run()
{
	if( state_ != UpdaterState::idle && state_ != UpdaterState::failed &&
		state_ != UpdaterState::newversion && state_ != UpdaterState::newversion_ready )
	{
		return false;
	}

	wxDateTime const t = wxDateTime::Now();
	COptions::Get()->SetOption(OPTION_UPDATECHECK_LASTDATE, t.Format(_T("%Y-%m-%d %H:%M:%S")));

	local_file_.clear();
	log_ = wxString::Format(_("Started update check on %s\n"), t.Format());

	wxString build = CBuildInfo::GetBuildType();
	if( build.empty() ) {
		build = _("custom");
	}
	log_ += wxString::Format(_("Own build type: %s\n"), build);

	SetState(UpdaterState::checking);

	m_use_internal_rootcert = true;
	int res = Download(GetUrl(), wxString());

	if (res != FZ_REPLY_WOULDBLOCK) {
		SetState(UpdaterState::failed);
	}
	raw_version_information_.clear();

	return state_ == UpdaterState::checking;
}
コード例 #6
0
bool wxDatePickerCtrl::Create(wxWindow *parent,
                              wxWindowID id,
                              const wxDateTime& dt,
                              const wxPoint& pos,
                              const wxSize& size,
                              long style,
                              const wxValidator& validator,
                              const wxString& name)
{
    if(!wxControl::Create(parent, id, pos, size, style, validator, name))
        return false;

    wxString label;

    if ( dt.IsValid() )
    {
        label = dt.FormatDate();
        m_dt = dt;
    }

    if(!wxControl::PalmCreateControl(selectorTriggerCtl, label, pos, size))
        return false;

    return true;
}
コード例 #7
0
void HumanoidDataLogger::saveData()
{
	const wxDateTime now = wxDateTime::UNow();
	
	wxString dataDirectory(dataSaveDirectory.c_str(),wxConvUTF8);
	wxString curFilePath = dataDirectory + wxT("/recentData.dat");
	
	dataDirectory += now.FormatISODate();
	wxString dataFile =  now.FormatISODate() + wxT("_") + now.FormatISOTime() + wxT(".dat");
	dataFile.Replace(wxT(":"), wxT("-"));
	
	wxString dataPath = dataDirectory + wxT("/") + dataFile;
	
	if(! wxDirExists(dataDirectory))
	{
		wxMkdir(dataDirectory);	
	}
	
	stringstream ss;
	ss << dataPath.mb_str();
	setFile(ss.str());
	writeRecords();
	
	FILE * curFile = fopen(curFilePath.mb_str(),"w");
	fprintf(curFile, "%s",ss.str().c_str());
	fclose(curFile);
}
コード例 #8
0
ファイル: eDocumentPath.cpp プロジェクト: joeri/e
//
// Returns true if this Cygwin installation should be updated (or installed for the first time.)
// Returns false if we are up-to-date.
//
bool eDocumentPath_shouldUpdateCygwin(wxDateTime &stampTime, const wxFileName &supportFile){
	// E's support folder comes with a network installer for Cygwin.
	// Newer versions of E may come with newer Cygwin versions.
	// If the user already has Cygwin installed, we still check the
	// bundled installer to see if it is newer; if so, then we need to
	// re-install Cygwin at the newer version.

	if (!stampTime.IsValid())
		return true; // First time, so we need to update.

	wxDateTime updateTime = supportFile.GetModificationTime();

	// Windows doesn't store milliseconds; we clear out this part of the time.
	updateTime.SetMillisecond(0);
	updateTime.SetSecond(0);

	stampTime.SetMillisecond(0);
	stampTime.SetSecond(0);

	// If the times are the same, no update needed.
	if (updateTime == stampTime)
		return false;

	// ...else the dates differ and we need to update.
	wxLogDebug(wxT("InitCygwin: Diff dates"));
	wxLogDebug(wxT("  e-postinstall: %s"), updateTime.FormatTime());
	wxLogDebug(wxT("  last-e-update: %s"), stampTime.FormatTime());
	return true;
}
コード例 #9
0
ファイル: clock.cpp プロジェクト: mookiejones/OpenCPN
void DashboardInstrument_Moon::SetUtcTime( wxDateTime data )
{
    if (data.IsValid())
    {
        m_phase = moon_phase(data.GetYear(), data.GetMonth() + 1, data.GetDay());
    }
}
コード例 #10
0
ファイル: converter.cpp プロジェクト: EEmmanuel7/wxWidgets
QDate wxQtConvertDate(const wxDateTime& date)
{
    if ( date.IsValid() )
        return QDate(date.GetYear(), date.GetMonth() + 1, date.GetDay());
    else
        return QDate();
}
コード例 #11
0
void serverPage::EnableCaching(wxDateTime expire_date) {
    D(debug("serverPage::EnableCaching(%s)\n", expire_date.Format(wxDefaultDateTimeFormat).c_str()));

    m_bEnableCaching    = true;
    m_sCacheExpires     = expire_date.Format(wxT("%a, %d %b %Y %T GMT") , wxDateTime::UTC );

    return;
}
コード例 #12
0
ファイル: Track.cpp プロジェクト: SamsonovAnton/OpenCPN
void TrackPoint::SetCreateTime( wxDateTime dt )
{
    wxString ts;
    if(dt.IsValid())
        ts = dt.FormatISODate().Append(_T("T")).Append(dt.FormatISOTime()).Append(_T("Z"));

    SetCreateTime(ts);
}
コード例 #13
0
pgsDateTimeGen::pgsDateTimeGen(wxDateTime min, wxDateTime max,
		const bool & sequence, const long & seed) :
	pgsObjectGen(seed), m_min(min.IsEarlierThan(max) || min.IsEqualTo(max) ? min : max),
			m_max(max.IsLaterThan(min) || max.IsEqualTo(min) ? max : min),
			m_range(m_max.Subtract(m_min).GetSeconds()), m_sequence(sequence)
{
	m_randomizer = pgsRandomizer(pnew pgsIntegerGen(0, std::string(m_range
			.ToString().mb_str()).c_str(), is_sequence(), m_seed));
}
コード例 #14
0
wxString FormatDateLong( const wxDateTime &aDate )
{
    /* GetInfo was introduced only on wx 2.9; for portability reason an
     * hardcoded format is used on wx 2.8 */
#if wxCHECK_VERSION( 2, 9, 0 )
    return aDate.Format( wxLocale::GetInfo( wxLOCALE_LONG_DATE_FMT ) );
#else
    return aDate.Format( wxT("%d %b %Y") );
#endif
}
コード例 #15
0
wxString otcurrentUIDialog::MakeDateTimeLabel(wxDateTime myDateTime)
{			
    const wxString dateLabel(myDateTime.Format( _T( "%a") ));
    m_staticTextDatetime->SetLabel(dateLabel);
    
    m_datePickerDate->SetValue(myDateTime.GetDateOnly());
    m_timePickerTime->SetTime(myDateTime.GetHour(),myDateTime.GetMinute(), myDateTime.GetSecond());

    return dateLabel;
}
コード例 #16
0
ファイル: budget.cpp プロジェクト: vomikan/moneymanagerex
void mmReportBudget::SetDateToEndOfYear(const int day, const int month, wxDateTime& date, bool isEndDate) const
{
    date.SetDay(day);
    date.SetMonth((wxDateTime::Month)month);
    if (isEndDate)
    {
        date.Subtract(wxDateSpan::Day());
        date.Add(wxDateSpan::Year());
    }
}
コード例 #17
0
ファイル: compdateaxis.cpp プロジェクト: lukecian/wxfreechart
wxDateTime RoundDateToSpan(wxDateTime date, wxDateSpan span)
{
    wxDateTime::wxDateTime_t day = date.GetDay();
    int month = MonthNum(date.GetMonth());
    wxDateTime::wxDateTime_t year = date.GetYear();

    wxDateTime::wxDateTime_t modDays = Mod(day - 1, span.GetTotalDays());
    wxDateTime::wxDateTime_t modMonths = Mod(month - 1, span.GetMonths());
    wxDateTime::wxDateTime_t modYears = Mod(year, span.GetYears());

    return wxDateTime(day - modDays, MonthFromNum(month - modMonths), year - modYears);
}
コード例 #18
0
ファイル: pgsTimeGen.cpp プロジェクト: lhcezar/pgadmin3
pgsTimeGen::pgsTimeGen(wxDateTime min, wxDateTime max, const bool & sequence,
		const long & seed) :
	pgsObjectGen(seed), m_min(min.IsEarlierThan(max) || min.IsEqualTo(max) ? min : max),
			m_max(max.IsLaterThan(min) || max.IsEqualTo(min) ? max : min),
			m_range(m_max.Subtract(m_min).GetSeconds()), m_sequence(sequence)
{
	m_min.SetYear(1970); // We know this date is not a DST date
	m_min.SetMonth(wxDateTime::Jan);
	m_min.SetDay(1);
	m_randomizer = pgsRandomizer(pnew pgsIntegerGen(0, std::string(m_range
			.ToString().mb_str()).c_str(), is_sequence(), m_seed));
}
コード例 #19
0
ファイル: datectrl.cpp プロジェクト: nE0sIghT/wxWidgets
wxDateTime wxDatePickerCtrl::GetValue() const
{
#if wxDEBUG_LEVEL
    const wxDateTime dt = MSWGetControlValue();

    wxASSERT_MSG( m_date.IsValid() == dt.IsValid() &&
                    (!dt.IsValid() || dt == m_date),
                  wxT("bug in wxDateTimePickerCtrl: m_date not in sync") );
#endif // wxDEBUG_LEVEL

    return wxDateTimePickerCtrl::GetValue();
}
コード例 #20
0
ファイル: calctrl.cpp プロジェクト: iokto/newton-dynamics
bool
wxGtkCalendarCtrl::SetDateRange(const wxDateTime& lowerdate,
                                const wxDateTime& upperdate)
{
    if ( lowerdate.IsValid() && upperdate.IsValid() && lowerdate >= upperdate )
        return false;

    m_validStart = lowerdate;
    m_validEnd = upperdate;

    return true;
}
コード例 #21
0
ファイル: BoatPlan.cpp プロジェクト: did-g/weather_routing_pi
/* this is not actually all that accurate (no oblate earth, refraction etc...
   but it's at least simple, could fix and optimize to only compute if
   there are possible plans which need this */
static bool ComputeDayTime(const wxDateTime &gribtime, double lat, double lon, int &daytime)

{
    if(daytime != -1)
        return daytime != 0;

    double yearpos = 2*M_PI*(gribtime.GetDay()-186)/365.24;
    double gha = 2*M_PI*(lon/15 - gribtime.GetHour() - gribtime.GetMinute()/60)/24;
    double suninc = 90*cos(deg2rad(lat))*sin(gha) + 23.45*cos(yearpos);    

    return (daytime = (suninc > 0)) != 0; /* sun above horizon */
}
コード例 #22
0
void ConfigurationDialog::SetStartDateTime(wxDateTime datetime)
{
    if(datetime.IsValid()) {
        m_dpStartDate->SetValue(datetime);
        m_tStartHour->SetValue(wxString::Format(_T("%.3f"), datetime.GetHour()
                                                +datetime.GetMinute() / 60.0));
    } else {
        wxMessageDialog mdlg(this, _("Invalid Date Time."),
                             wxString(_("Weather Routing"), wxOK | wxICON_WARNING));
        mdlg.ShowModal();
    }
}
コード例 #23
0
ファイル: nwxString.cpp プロジェクト: HelloWilliam/osiris
wxString nwxString::FormatDateTime(const wxDateTime &dt, const wxString &sDefault)
{
  wxString sRtn;
  if(dt.GetTicks() == 0)
  {
    sRtn = sDefault;
  }
  else
  {
    sRtn = dt.Format(nwxString::TIME_FORMAT);
  }
  return sRtn;
}
コード例 #24
0
wxGzipOutputStream::wxGzipOutputStream(
                        wxOutputStream& stream,
                        const wxString& originalName /*=wxEmptyString*/,
#if wxUSE_DATETIME
                        const wxDateTime& originalTime /*=wxDateTime::Now()*/,
#endif
                        int level /*=-1*/,
                        wxMBConv& conv /*=wxConvFile*/)
  : wxFilterOutputStream(stream)
{
    m_comp = NULL;
    m_crc = crc32(0, Z_NULL, 0);

    wxFileName filename(originalName);

    wxUint32 timestamp = 0;
#if wxUSE_DATETIME
    if (originalTime.IsValid())
        timestamp = (originalTime.GetValue() / 1000L).GetLo();
#endif

    // RFC-1952 specifies ISO-8859-1 for the name. Also it should be just the
    // name part, no directory, folded to lowercase if case insensitive
    wxString name = filename.GetFullName();
    const wxWX2MBbuf mbName = conv.cWX2MB(name);
    
    wxDataOutputStream ds(*m_parent_o_stream);

    // write signature, method, flags, timestamp, extra flags and OS-code
    ds.Write16(GZ_MAGIC);
    ds.Write8(Z_DEFLATED);
    ds.Write8(mbName && *mbName ? GZ_ORIG_NAME : 0);
    ds.Write32(timestamp);
    ds.Write8(level == 1 ? GZ_FASTEST : level == 9 ? GZ_SLOWEST : 0);
    ds.Write8(255);

    if (mbName && *mbName)
        m_parent_o_stream->Write(mbName, strlen(mbName) + 1);

    m_lasterror = wxSTREAM_WRITE_ERROR;
    if (!*m_parent_o_stream) {
        wxLogDebug(wxT("Error writing Gzip header"));
        return;
    }

    m_comp = new wxZlibOutputStream(*m_parent_o_stream, level, wxZLIB_NO_HEADER);

    if (m_comp)
        m_lasterror = m_comp->GetLastError();
}
コード例 #25
0
ファイル: drawview.cpp プロジェクト: cyclefusion/szarp
void GraphView::GetDistance(int x, int y, double &d, wxDateTime &time) const {
	d = INFINITY;
	time = wxInvalidDateTime;
	/* this defines search radius for 'direct hit' */

	int w,h;
	m_dc->GetSize(&w, &h);
	
	/* forget about top and bottom margins */
	h -= m_bottommargin + m_topmargin;
	/* get X coordinate */
	int index = GetIndex(x);

	const Draw::VT& vt = m_draw->GetValuesTable();
    
	int i, j;
	for (i = j = index; i >= 0 || j < (int)vt.size(); --i, ++j) {
		double d1 = INFINITY;
		double d2 = INFINITY;

		if (i >= 0 && i < (int)vt.size() && vt.at(i).IsData()) {
			int xi, yi;
			GetPointPosition(m_dc, i, &xi, &yi);
			d1 = (x - xi) * (x - xi) + (y - yi) * (y - yi);
		}

		if (j >= 0 && j < (int)vt.size() && vt.at(j).IsData()) {
			int xj, yj;
			GetPointPosition(m_dc, j, &xj, &yj);
			d1 = (x - xj) * (x - xj) + (y - yj) * (y - yj);
		}

		if (!std::isfinite(d1) && !std::isfinite(d1))
			continue;

		if (!std::isfinite(d2) || d1 < d2) {
			d = d1;
			time = m_draw->GetTimeOfIndex(i);
			wxLogInfo(_T("Nearest index %d, time: %s"), i, time.Format().c_str());
		} else {
			d = d2;
			time = m_draw->GetTimeOfIndex(j);
			wxLogInfo(_T("Nearest index %d, time: %s"), j, time.Format().c_str());
		}

		break;

	}

}
コード例 #26
0
ファイル: timectrlg.cpp プロジェクト: jfiguinha/Regards
    // Decrement or increment the value of the current field (wrapping if
    // necessary).
    void ChangeCurrentFieldBy1(Direction dir)
    {
        switch ( m_currentField )
        {
            case Field_Hour:
                m_time.SetHour((m_time.GetHour() + 24 + dir) % 24);
                break;

            case Field_Min:
                m_time.SetMinute((m_time.GetMinute() + 60 + dir) % 60);
                break;

            case Field_Sec:
                m_time.SetSecond((m_time.GetSecond() + 60 + dir) % 60);
                break;

            case Field_AMPM:
                m_time.SetHour((m_time.GetHour() + 12) % 24);
                break;

            case Field_Max:
                wxFAIL_MSG( "Invalid field" );
                return;
        }

        UpdateText();
    }
コード例 #27
0
ファイル: journalentry.cpp プロジェクト: Sonderstorch/c-mon
void CJournalEntry::setBegin(const wxDateTime& dt)
{
  // Avoid silly wxDateTime assertions ... (doh!)
  if (m_dtBegin.IsValid() && !dt.IsValid()) {
    m_bDirty = true;
  } else if (!m_dtBegin.IsValid() && dt.IsValid()) {
    m_bDirty = true;
  } else {
    if (m_dtBegin.IsValid() && dt.IsValid()) {
      m_bDirty = m_bDirty || (m_dtBegin != dt);
    }
  }
  m_dtBegin = dt;
}
コード例 #28
0
void wxDatePickerCtrl::SetValue(const wxDateTime& dt)
{
    wxCHECK_RET( dt.IsValid() || HasFlag(wxDP_ALLOWNONE),
                    wxT("this control requires a valid date") );

    SYSTEMTIME st;
    if ( dt.IsValid() )
    {
        // Don't try setting the date if it's out of range: calendar control
        // under XP (and presumably all the other pre-Vista Windows versions)
        // doesn't return false from DateTime_SetSystemtime() in this case but
        // doesn't actually change the date, so we can't update our m_date
        // unconditionally and would need to check whether it was changed
        // before doing it. It looks simpler to just check whether it's in
        // range here instead.
        //
        // If we ever drop support for XP we could rely on the return value of
        // DateTime_SetSystemtime() but this probably won't happen in near
        // future.
        wxDateTime dtStart, dtEnd;
        GetRange(&dtStart, &dtEnd);
        if ( (dtStart.IsValid() && dt < dtStart) ||
                (dtEnd.IsValid() && dt > dtEnd) )
        {
            // Fail silently, some existing code relies on SetValue() with an
            // out of range value simply doing nothing -- so don't.
            return;
        }

        dt.GetAsMSWSysTime(&st);
    }

    if ( !DateTime_SetSystemtime(GetHwnd(),
                                 dt.IsValid() ? GDT_VALID : GDT_NONE,
                                 &st) )
    {
        // The only expected failure is when the date is out of range but we
        // already checked for this above.
        wxFAIL_MSG( wxT("Setting the calendar date unexpectedly failed.") );

        // In any case, skip updating m_date below.
        return;
    }

    // we need to keep only the date part, times don't make sense for this
    // control (in particular, comparisons with other dates would fail)
    m_date = dt;
    if ( m_date.IsValid() )
        m_date.ResetTime();
}
コード例 #29
0
void GCDCGraphs::GetDistance(size_t draw_index, int x, int y, double &d, wxDateTime &time) {
	d = INFINITY;
	time = wxInvalidDateTime;
	/* this defines search radius for 'direct hit' */

	int w,h;
	GetClientSize(&w, &h);
	
	const Draw::VT& vt = m_draws[draw_index]->GetValuesTable();
	/* forget about top and bottom margins */
	h -= m_screen_margins.bottommargin + m_screen_margins.topmargin;
	/* get X coordinate */
	int index = GetIndex(x, vt.size());

	int i, j;
	for (i = j = index; i >= 0 || j < (int)vt.size(); --i, ++j) {
		double d1 = INFINITY;
		double d2 = INFINITY;

		if (i >= 0 && i < (int)vt.size() && vt.at(i).IsData()) {
			double xi = GetX(i);
			double yi = GetY(vt[i].val, m_draws[draw_index]->GetDrawInfo());
			d1 = (x - xi) * (x - xi) + (y - yi) * (y - yi);
		}

		if (j >= 0 && j < (int)vt.size() && vt.at(j).IsData()) {
			double xj = GetX(j);
			double yj = GetY(vt[j].val, m_draws[draw_index]->GetDrawInfo());
			d2 = (x - xj) * (x - xj) + (y - yj) * (y - yj);
		}

		if (!std::isfinite(d1) && !std::isfinite(d2))
			continue;

		if (!std::isfinite(d2) || d1 < d2) {
			d = d1;
			time = m_draws[draw_index]->GetTimeOfIndex(i);
			wxLogInfo(_T("Nearest index %d, time: %s"), i, time.Format().c_str());
		} else {
			d = d2;
			time = m_draws[draw_index]->GetTimeOfIndex(j);
			wxLogInfo(_T("Nearest index %d, time: %s"), j, time.Format().c_str());
		}

		break;

	}

}
コード例 #30
0
ファイル: util.cpp プロジェクト: twoubt/moneymanagerex
//* Date Functions----------------------------------------------------------*//
const wxString mmGetNiceDateSimpleString(const wxDateTime &dt)
{
    wxString dateFmt = mmOptions::instance().dateFormat_;
    dateFmt.Replace("%Y%m%d", "%Y %m %d");
    dateFmt.Replace(".", " ");
    dateFmt.Replace(",", " ");
    dateFmt.Replace("/", " ");
    dateFmt.Replace("-", " ");
    dateFmt.Replace("%d", wxString::Format("%d", dt.GetDay()));
    dateFmt.Replace("%Y", wxString::Format("%d", dt.GetYear()));
    dateFmt.Replace("%y", wxString::Format("%d", dt.GetYear()).Mid(2,2));
    dateFmt.Replace("%m", wxGetTranslation(wxDateTime::GetEnglishMonthName(dt.GetMonth())));

    return dateFmt;
}