wxDateTime TIniFile::ReadULongDateTime(const wxString &Section, const wxString &Ident, wxDateTime Default) { unsigned long WxTicks = ReadULong(Section, Ident, Default.GetTicks()); wxDateTime Result((time_t)WxTicks); return Result; }
bool DateChooserWidget::GetDate(wxDateTime &date) { int ret = wxID_OK; date_control->SetDate(date); hour_control->SetValue(date.GetHour()); minute_control->SetValue(date.GetMinute()); current_minute = date.GetMinute(); current_second = date.GetSecond(); while( (ret = ShowModal()) == wxID_OK){ date = date_control->GetDate(); // ustawiamy godzine date.SetHour(hour_control->GetValue()); date.SetMinute(minute_control->GetValue()); if (second_control) date.SetSecond(second_control->GetValue()); wxDateTime tmin(time_t(0)); wxDateTime tmax(MAX_TIME_T_FOR_WX_DATE_TIME); if (date <= tmin || date >= tmax) { wxMessageBox(_("Invalid (too large/small) date"), _("Error!"), wxOK); return false; } if (min_date == -1 && max_date == -1) return true; if(date.GetTicks() >= min_date && date.GetTicks() <= max_date) return true; else { wxString buf; buf = _("Please choose the date from between: "); buf += wxDateTime(min_date).Format(_T("%Y-%m-%d %H:%M ")); buf += _("and"); buf += wxDateTime(max_date).Format(_T(" %Y-%m-%d %H:%M\n")); wxMessageDialog *mesg = new wxMessageDialog(this, buf, _("Incorrect date range"), wxOK); mesg->ShowModal(); delete mesg; } } return false; }
double CompDateAxis::DateToDataCoord(wxDateTime &date) { wxDateTime firstDate, lastDate; if (!GetFirstLastDate(firstDate, lastDate)) { return 0; } double dataValue = m_dateCount * (double) (date.GetTicks() - firstDate.GetTicks()) / (double) (lastDate.GetTicks() - firstDate.GetTicks()); return dataValue; }
wxDateTime TIniFile::ReadTime(const wxString &Section, const wxString &Ident, wxDateTime Default) { long ticks = ReadLong(Section, Ident, Default.GetTicks()); if (ticks == 0) return Default; wxDateTime result (ticks); if (result.IsValid()) return result; else return Default; }
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; }
wxString logsWindow::timeAgo(wxDateTime currTime) { int delta = wxDateTime::Now().GetTicks() - currTime.GetTicks(); wxString timeString; if (delta == 0) { return _("Just now"); } else if (delta == 1) { return _("One second ago"); } else if (delta < MINUTE) { timeString.Printf(_("%i seconds ago"), delta); return timeString; } else if (delta < 2 * MINUTE) { return _("About a minute ago"); } else if (delta < 45 * MINUTE) { timeString.Printf(_("%i minutes ago"), delta/MINUTE); return timeString; } else if (delta < 90 * MINUTE) { return _("About an hour ago"); } else if (delta < DAY) { timeString.Printf(_("%i hours ago"), delta/HOUR); return timeString; } else if (delta < 48 * HOUR) { return _("Yesterday"); } else if (delta < 365 * DAY) { timeString.Printf(_("%i days ago"), delta/DAY); return timeString; } else { return wxEmptyString; } }
VALUE wrap< wxDateTime >(const wxDateTime &st ) { if(!st.IsValid()) return Qnil; return rb_time_new(st.GetTicks(),st.GetMillisecond() * 10); }
void TIniFile::WriteTime(const wxString &Section, const wxString &Ident, wxDateTime Value) { WriteLong(Section, Ident, Value.GetTicks()); }