Пример #1
0
date WCalendar::dateForCell(int week, int dayOfWeek)
{
  date d(currentYear_, currentMonth_, 1);
  d -= date_duration(1);
  greg_weekday gw = firstDayOfWeek_ % 7;
  d = previous_weekday(d, gw);

  d += date_duration(week * 7 + dayOfWeek);

  return d;
}
Пример #2
0
RunSequence::RunSequence( const boost::gregorian::date& dateStart ) 
  : m_portfolio( "test" ),
      m_stateTimeFrame( EPreOpen ), m_stateTrading( ENeutral ),
    m_timeOpeningBell( 19, 0, 0 ),
    m_timeCancelTrades( 16, 40, 0 ),
    m_timeClosePositions( 16, 45, 0 ),
    m_timeClosingBell( 17, 0, 0 ),
    m_dtOpeningBell( dateStart, m_timeOpeningBell ),
    m_dtStartTrading( m_dtOpeningBell + time_duration( 0, 16, 0 ) ),
    m_dtCancelTrades( dateStart + date_duration( 1 ), m_timeCancelTrades ),
    m_dtClosePositions( dateStart + date_duration( 1 ), m_timeClosePositions ),
    m_dtClosingBell( dateStart + date_duration( 1 ), m_timeClosingBell )
{
}
Пример #3
0
 inline
 std::basic_istream<charT>& operator>>(std::basic_istream<charT>& is, 
                                       date_duration& dd)
 {
   long v;
   is >> v;
   dd = date_duration(v);
   return is;
 }
Пример #4
0
WDate WDate::addDays(int ndays) const
{
  if (valid_) {
    date d(year_, month_, day_);
    d += date_duration(ndays);

    return WDate(d.year(), d.month(), d.day());
  } else
    return *this;
}
Пример #5
0
void WCalendar::render(WFlags<RenderFlag> flags)
{
  if (needRenderMonth_) {
    bool create = cellClickMapper_ == 0;
#ifndef WT_TARGET_JAVA
    char buf[30];
#else
    char *buf;
#endif // WT_TARGET_JAVA

    if (create) {
      // FIXME catch events only on container, and use 'tid' to identify
      // the cell -- in Ajax mode
      cellClickMapper_ = new WSignalMapper<Coordinate>(this);
      cellClickMapper_->mapped().connect(this, &WCalendar::cellClicked);
      cellDblClickMapper_ = new WSignalMapper<Coordinate>(this);
      cellDblClickMapper_->mapped().connect(this, &WCalendar::cellDblClicked);
    }

    int m = currentMonth_ - 1;
    if (monthEdit_->currentIndex() != m)
      monthEdit_->setCurrentIndex(m);

    int y = currentYear_;
    Utils::itoa(y, buf);
    if (yearEdit_->text().toUTF8() != buf)
      yearEdit_->setText(WString::fromUTF8(buf));

    WDate todayd = WDate::currentDate();
    date today(todayd.year(), todayd.month(), todayd.day());

    // The first line contains the last day of the previous month.
    date d(currentYear_, currentMonth_, 1);
    d -= date_duration(1);
 
    greg_weekday gw = firstDayOfWeek_ % 7;
    d = previous_weekday(d, gw);

    for (unsigned i = 0; i < 6; ++i) {
      for (unsigned j = 0; j < 7; ++j) {
	Utils::itoa(i * 7 + j, buf);
	std::string cell = std::string("c") + buf;
	
	WDate date(d.year(), d.month(), d.day());

	WWidget *w = impl_->resolveWidget(cell);
	WWidget *rw = renderCell(w, date);
	impl_->bindWidget(cell, rw);

	WInteractWidget* iw = dynamic_cast<WInteractWidget*>(rw->webWidget());

	if (iw && iw != w) {
	  if (clicked().isConnected()
	      || (selectionMode_ == ExtendedSelection)
	      || (selectionMode_ != ExtendedSelection && singleClickSelect_
		  && activated().isConnected()))
	    cellClickMapper_
	      ->mapConnect(iw->clicked(), Coordinate(i, j));

	  if ((selectionMode_ != ExtendedSelection && !singleClickSelect_
	       && (activated().isConnected() ||
		   selectionChanged().isConnected())))
	    cellDblClickMapper_
	      ->mapConnect(iw->doubleClicked(), Coordinate(i, j));
	}

	d += date_duration(1);
      }
    }

    needRenderMonth_ = false;
  }

  WCompositeWidget::render(flags);
}
 //! Returns the smallest duration -- used by to calculate 'end'
 static date_duration unit()
 {
   return date_duration(base_type::unit().get_rep());
 }
 //! unary- Allows for dd = -date_duration(2); -> dd == -2
 date_duration operator- ()const
 {
   return date_duration(get_rep() * (-1));
 }