本文整理汇总了C++中DateTime::SetHour方法的典型用法代码示例。如果您正苦于以下问题:C++ DateTime::SetHour方法的具体用法?C++ DateTime::SetHour怎么用?C++ DateTime::SetHour使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DateTime
的用法示例。
在下文中一共展示了DateTime::SetHour方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: calcSpacedDaysHours
void Ambient::calcSpacedDaysHours(double lat, double lon, double tmz, int nday, double delta_hr, vector<vector<double> > &utime, vector<int> &uday){
//Method taken from PTGen code (Wagner 2008 thesis)
double pi = PI;
uday.resize(nday);
vector<int>
ntstep(nday),
ntstep_day(nday);
vector<double>
noons(nday),
hours(nday);
DateTime DT;
int month, dom;
for(int i=0; i<nday; i++){
//Calculate the day number - The days are evenly distributed over the cosine wave of the year
uday[i] = 355 - (int)floor(acos(-1.+2.*i/(float)(nday-1))/pi*(float)(355-172));
DT.hours_to_date(uday[i]*24 +12., month, dom);
DT.SetHour(12);
DT.SetDate(2011, month, dom);
DT.SetYearDay(uday[i]);
double hrs[2];
Ambient::calcDaytimeHours(hrs, lat*D2R, lon*D2R, tmz, DT);
noons.at(i) = (hrs[0]+hrs[1])/2.;
//shorten the time by 0.9 so we don't get stuff really close to the horizon
ntstep[i] = (int)floor( (hrs[1]-noons.at(i))*.9/delta_hr );
//For the calculated day, determine the solar declination angle and the number of daylight hours
//delta[i] = asin(23.45*D2R*cos((float)(uday[i]-173)*D2R));
//nhour[i] = (int)(floor((2./15.*acos(-tan(phi)*tan(delta[i]))*r2d)/2.));
ntstep_day[i] = 2*ntstep[i]+1;
}
//Store the day and time in the utime array
utime.clear();
vector<double> utemp;
int nflux_sim = 0;
for(int i=0; i<nday; i++){
utemp.clear();
for(int j=0; j<ntstep_day[i]; j++){
utemp.push_back( noons[i]+(-ntstep[i]+j)*delta_hr -12.);
nflux_sim++;
}
utime.push_back(utemp);
}
}
示例2: setDateTime
void Ambient::setDateTime(DateTime &DT, double day_hour, double year_day, double year){
DT.setZero();
double min, sec;
min = (day_hour - floor(day_hour))*60.;
sec = (min - floor(min))*60.;
DT.SetHour(int(floor(day_hour)));
DT.SetMinute(int(min));
DT.SetSecond(int(sec));
DT.SetYearDay(int(year_day));
DT.SetYear(int(year));
int month, dom;
DT.hours_to_date((year_day-1)*24.+day_hour, month, dom);
DT.SetMonth(int(month));
DT.SetMonthDay(int(dom));
}