//----------------------------------------Functions In Development-----------------------
bool format_price_days(vector <struct historicalprices> prev_price, float formated_price[]){
    unsigned int lastcounter= 0, num_prev = prev_price.size(), num_form = sizeof(formated_price);
    for(unsigned int i = 0; i < num_form; i++){
        for(unsigned int j=0; j < num_prev; j++){
            if (yday(prev_price[j].date) == today.getyday()-lastcounter){
                formated_price[i] = prev_price[j].close;
            }
            lastcounter ++;
        }
    }
}
示例#2
0
void TimeStamp::decode_date(ISC_DATE nday, struct tm* times)
{
	// Convert a numeric day to [day, month, year].
	//
	// Calenders are divided into 4 year cycles: 3 non-leap years, and 1 leap year.
	// Each cycle takes 365*4 + 1 == 1461 days.
	// There is a further cycle of 100 4 year cycles.
	// Every 100 years, the normally expected leap year is not present. Every 400 years it is.
	// This cycle takes 100 * 1461 - 3 == 146097 days.
	// The origin of the constant 2400001 is unknown.
	// The origin of the constant 1721119 is unknown.
	// The difference between 2400001 and 1721119 is the
	// number of days from 0/0/0000 to our base date of 11/xx/1858 (678882)
	// The origin of the constant 153 is unknown.
	//
	// This whole routine has problems with ndates less than -678882 (Approx 2/1/0000).

	// struct tm may include arbitrary number of additional members.
	// zero-initialize them.
	memset(times, 0, sizeof(struct tm));

	if ((times->tm_wday = (nday + 3) % 7) < 0)
		times->tm_wday += 7;

	nday += 2400001 - 1721119;
	const int century = (4 * nday - 1) / 146097;
	nday = 4 * nday - 1 - 146097 * century;
	int day = nday / 4;

	nday = (4 * day + 3) / 1461;
	day = 4 * day + 3 - 1461 * nday;
	day = (day + 4) / 4;

	int month = (5 * day - 3) / 153;
	day = 5 * day - 3 - 153 * month;
	day = (day + 5) / 5;

	int year = 100 * century + nday;

	if (month < 10)
		month += 3;
	else {
		month -= 9;
		year += 1;
	}

	times->tm_mday = day;
	times->tm_mon = month - 1;
	times->tm_year = year - 1900;

	times->tm_yday = yday(times);
}
示例#3
0
/*------------------------------------------------------------------------
 * number of seconds since Jan 1, 1970 UTC
 */
time_t ogc_datetime :: unixtime() const
{
   time_t secs = 0;

   if ( _year >= 1970 )
   {
      secs  = ((_year - 1970) * 365);
      secs += ((_year - 1969) / 4);
      secs += yday();
      secs *= (24 * 60 * 60);

      secs += _hour * (60 * 60);
      secs += _min  * (60);
      secs += (int)_sec;

      secs += (_tz * 60);
   }

   return secs;
}