QString Percentile::getFemaleHeight(QDateTime birthday, double measure) { QString a; a = "Unknown"; if (isweekMinorOf13(birthday.date())) { int nweek = week(birthday.date()); if (femaleMapHeight13Week == NULL) femaleMapHeight13Week = new PercentileMap(":/data/tab_lhfa_girls_p_0_13.txt", this); Interval percentile = femaleMapHeight13Week->find(nweek, measure); a = intervalString(percentile); }else { int nmonth = month(birthday.date()); if (nmonth < 25) { if (femaleMapHeight2Year == NULL) femaleMapHeight2Year = new PercentileMap(":/data/tab_lhfa_girls_p_0_2.txt", this); Interval percentile = femaleMapHeight2Year->find(nmonth, measure); fprintf(stdout, "percentile %d", percentile); fflush(stdout); a = intervalString(percentile); } else if (nmonth >= 25 && nmonth <= 60) { if (femaleMapHeight5Year == NULL) femaleMapHeight5Year = new PercentileMap(":/data/tab_lhfa_girls_p_2_5.txt", this); Interval percentile = femaleMapHeight5Year->find(nmonth, measure); a = intervalString(percentile); } } return a; }
bool Timezone::isBeforeTransition(const Date& date,UInt32 clock,const TransitionRule& rule) { // Consider that we are on the same month, and rule!=NIL! (caller checking) if (rule.type == TransitionRule::ABSOLUTE) { if (date.yearDay()<rule.day) return true; } else if (rule.type == TransitionRule::JULIAN) { UInt16 day(date.yearDay()); if (date.month()>2 && Date::IsLeapYear(date.year())) --day; if (day<rule.day) return true; } else { //RELATIVE UInt8 days = (date.day() + 6 - date.weekDay()); UInt8 week(days/7); if ((days%7) > 0 && week<5) ++week; // before week? if (week < rule.week) return true; // before day? if (date.weekDay() < rule.day) return true; } // before clock? return clock<rule.clock; }
QString Percentile::getMaleHead(QDateTime birthday, double measure) { QString a; a = "Unknown"; if (isweekMinorOf13(birthday.date())) { int nweek = week(birthday.date()); if (maleMapHead13Week == NULL) maleMapHead13Week = new PercentileMap(":/tab_hcfa_boys_p_0_13.txt", this); Interval percentile = maleMapHead13Week->find(nweek, measure); a = intervalString(percentile); }else { int nmonth = month(birthday.date()); if (nmonth >= 0 && nmonth <= 60) { if (maleMapHead5Year == NULL) maleMapHead5Year = new PercentileMap(":/tab_hcfa_boys_p_0_5.txt", this); Interval percentile = maleMapHead5Year->find(nmonth, measure); a = intervalString(percentile); } } return a; }
void monthly(int month, int year) { int col, row, len, days[MAXDAYS], firstday; char *p, lineout[30]; day_array(month, year, days); (void)snprintf(lineout, sizeof(lineout), "%s %d", month_names[month - 1], year); len = strlen(lineout); (void)printf("%*s%s\n%s\n", ((julian ? J_WEEK_LEN : WEEK_LEN) - len) / 2, "", lineout, day_headings); for (row = 0; row < 6; row++) { firstday = SPACE; for (col = 0, p = lineout; col < 7; col++, p += julian ? J_DAY_LEN : DAY_LEN) { if (firstday == SPACE && days[row * 7 + col] != SPACE) firstday = days[row * 7 + col]; ascii_day(p, days[row * 7 + col]); } *p = '\0'; trim_trailing_spaces(lineout); (void)printf("%-20s", lineout); if (wflag && firstday != SPACE) printf(" [%2d]", week(firstday, month, year)); printf("\n"); } }
QString Percentile::getFemaleWeight(QDateTime birthday, double measure) { QString a; a = "Unknown"; qDebug() << "IN getFemaleWeight " << endl; if (isweekMinorOf13(birthday.date())) { int nweek = week(birthday.date()); if (femaleMapWeight13Week == NULL) femaleMapWeight13Week = new PercentileMap(":/data/tab_wfa_girls_p_0_13.txt", this); Interval percentile = femaleMapWeight13Week->find(nweek, measure); a = intervalString(percentile); }else { int nmonth = month(birthday.date()); if (nmonth >= 0 && nmonth <= 60) { if (femaleMapWeight5Year == NULL) femaleMapWeight5Year = new PercentileMap(":/data/tab_wfa_girls_p_0_5.txt", this); Interval percentile = femaleMapWeight5Year->find(nmonth, measure); qDebug() << "PErcemtila " << percentile << endl; a = intervalString(percentile); } } return a; }
function plotWeek(var value,int type) { int periods = (4*24 + 22); LookBack = max(LookBack,periods); int h = hour() + 24*(dow()-1); if(h > periods) return; plotSeason(h,hour(),week(),value,type); }
function plotYear(var value,int type) { int periods = 52*5; LookBack = max(LookBack,periods); int n = (week()-1)*5 + dow()-1; if(n > periods) return; plotSeason(n,month(),year(),value,type); }
/** * the user selected recurrence rule. * @return The recurrence rule. */ ORecur ORecurranceWidget::recurrence()const { QListIterator<QToolButton> it( listRTypeButtons ); QListIterator<QToolButton> itExtra( listExtra ); ORecur rpTmp; int i; for ( i = 0; *it; ++it, i++ ) { if ( (*it)->isOn() ) { switch ( i ) { case None: rpTmp.setType( ORecur::NoRepeat ); break; case Day: rpTmp.setType( ORecur::Daily ); break; case Week:{ rpTmp.setType( ORecur::Weekly ); int day; int day2 = 0; for ( day = 1; *itExtra; ++itExtra, day = day << 1 ) { if ( (*itExtra)->isOn() ) { if ( startWeekOnMonday ) day2 |= day; else { if ( day == 1 ) day2 |= Event::SUN; else day2 |= day >> 1; } } } rpTmp.setDays( day2 ); } break; case Month: if ( cmdExtra1->isOn() ) rpTmp.setType( ORecur::MonthlyDay ); else if ( cmdExtra2->isOn() ) rpTmp.setType( ORecur::MonthlyDate ); // figure out the montly day... rpTmp.setPosition( week( start ) ); break; case Year: rpTmp.setType( ORecur::Yearly ); break; } break; // no need to keep looking! } } rpTmp.setFrequency(spinFreq->value() ); rpTmp.setHasEndDate( !chkNoEnd->isChecked() ); if ( rpTmp.hasEndDate() ) { rpTmp.setEndDate( end ); } // timestamp it... // rpTmp.setCreateTime( ); current DateTime is already set -zecke return rpTmp; }
void ORecurranceWidget::slotMonthLabel(int type) { QString str; if ( currInterval != Month || type > 1 ) return; if ( type == 1 ) str = strMonthDateTemplate.arg( numberPlacing(start.day()) ); else str = strMonthDayTemplate.arg( numberPlacing(week(start))) .arg( dayLabel[start.dayOfWeek() - 1] ); lblRepeat->setText( str ); }
QString Percentile::getAge(QDateTime birthday) { QString ageString; if (isweekMinorOf13(birthday.date())) { int nweek = week(birthday.date()); ageString = QString::number(nweek) + " weeks"; } else { int nmonth = month(birthday.date()); ageString = QString::number(nmonth) + " months"; } return ageString; }
void yearly(int year) { int col, *dp, i, month, row, which_cal, week_len, wn, firstday; int days[12][MAXDAYS]; char *p, lineout[81]; week_len = WEEK_LEN; if (wflag) week_len += WEEKNUMBER_LEN; (void)snprintf(lineout, sizeof(lineout), "%d", year); center(lineout, week_len * 3 + HEAD_SEP * 2, 0); (void)printf("\n\n"); for (i = 0; i < 12; i++) day_array(i + 1, year, days[i]); (void)memset(lineout, ' ', sizeof(lineout) - 1); lineout[sizeof(lineout) - 1] = '\0'; for (month = 0; month < 12; month += 3) { center(month_names[month], week_len, HEAD_SEP); center(month_names[month + 1], week_len, HEAD_SEP); center(month_names[month + 2], week_len, 0); (void)printf("\n%s%*s%s%*s%s\n", day_headings, HEAD_SEP + (wflag ? WEEKNUMBER_LEN : 0), "", day_headings, HEAD_SEP + (wflag ? WEEKNUMBER_LEN : 0), "", day_headings); for (row = 0; row < 6; row++) { for (which_cal = 0; which_cal < 3; which_cal++) { p = lineout + which_cal * (week_len + 2); dp = &days[month + which_cal][row * 7]; firstday = SPACE; for (col = 0; col < 7; col++, p += DAY_LEN) { if (firstday == SPACE && *dp != SPACE) firstday = *dp; ascii_day(p, *dp++); } if (wflag && firstday != SPACE) { wn = week(firstday, month + which_cal + 1, year); (void)snprintf(p, 5, "[%2d]", wn); p += strlen(p); *p = ' '; } else memset(p, ' ', 4); } *p = '\0'; trim_trailing_spaces(lineout); (void)printf("%s\n", lineout); } } (void)printf("\n"); }
void make_cal(int month, int year, int cal[CAL_V][CAL_H]){ int nd, wd; int i, j, d; for(i=0;i<CAL_V;i++){ for(j=0;j<CAL_H;j++){ cal[i][j] = 0; } } nd = days(month, year); wd = week(1, month, year); for(d=1, i=0, j=wd;d<=nd;d++, j++){ if(j>=CAL_H){ j = 0; i++; } cal[i][j] = d; } }
bool Timezone::ParseTZRule(string::const_iterator& it,const string::const_iterator& end,TransitionRule& rule) { if (it == end) return false; TransitionRule::Type type(TransitionRule::NIL); UInt8 month(0), week(0), day(0); if (*it == 'J' && ++it!=end) { while (it!=end && isdigit(*it)) { day = day*10 + ((*it)-'0'); ++it;} // julian day (1 to 365 without leap counted) if (day>0) type = TransitionRule::JULIAN; } else if (*it == 'M' && ++it!=end) { while (it != end && isdigit(*it)) { month = month*10 + ((*it)-'0'); ++it; } // month if (it != end && *it == '.') { ++it; while (it != end && isdigit(*it)) { week = week*10 + ((*it)-'0'); ++it; } } // week if (it != end && *it == '.') { ++it; while (it != end && isdigit(*it)) { day = day*10 + ((*it)-'0'); ++it; } } // day if (month>0 && week>0) type = TransitionRule::RELATIVE; } else { while (it!=end && isdigit(*it)) { day = day*10 + ((*it)-'0'); ++it;} // absolute day (0 to 365 with leap counted) if (day>0) type = TransitionRule::ABSOLUTE; } if (type==TransitionRule::NIL) return false; rule.type = type; rule.month = month; rule.week = week; rule.day = day; if (it != end && *it == '/') { bool gotten(false); month = week = day = 0; ++it; while (it != end && isdigit(*it)) { month = month * 10 + ((*it) - '0'); ++it; gotten = true; } // hour if (!gotten) { rule.clock = month*3600000; return true; } if (it != end && *it == ':') { ++it; while (it != end && isdigit(*it)) { week = week*10 + ((*it)-'0'); ++it; } } // minute rule.clock += week*60000; if (it != end && *it == ':') { ++it; while (it != end && isdigit(*it)) { day = day*10 + 1000 * ((*it)-'0'); ++it; } } // second rule.clock += day*1000; } return true; }
void CEmTubePlaylistManager::RemoveOutdatedEntries( CEmTubePlaylist* aPlaylist ) { TTime weekago; weekago.HomeTime(); TTimeIntervalHours week( 24*7 ); weekago -= week; TInt count = aPlaylist->EntriesCount(); for(TInt i=count-1;i>0;i--) { CEmTubePlaylistEntry *e = aPlaylist->Entry( i ); TTimeIntervalHours diff; e->Time().HoursFrom( weekago, diff ); if( diff > week ) { aPlaylist->RemoveEntry( i ); delete e; } else { break; } } }
void t4p::VersionUpdateViewClass::OnUpdateCheckComplete(wxCommandEvent& event) { wxString nextVersion = event.GetString(); wxString currentVersion = Feature.GetCurrentVersion(); if (!nextVersion.empty()) { VersionUpdateDialogClass dialog(GetMainWindow(), wxID_ANY, Feature.App.RunningThreads, currentVersion, true, nextVersion); dialog.ShowModal(); } // do another check a week from today Feature.NextCheckTime = wxDateTime::Now(); wxDateSpan week(0, 0, 1, 0); Feature.NextCheckTime.Add(week); // write the check time to the config // NOTE: we check if settings dir has been set, if it has not // been set, then we cannot write the config to a file // because the user has not chosen a settings directory // since the version check is triggered during the app ready // event, during the very first run the user has not yet // chosen a settings dir, and the config is not usable // TODO(roberto): we should prevent config from being read // before the user has chosen a settings dir, or // provide a default settings dir wxFileName settingsDir = t4p::SettingsDirAsset(); if (settingsDir.IsOk()) { wxConfigBase* config = wxConfig::Get(); config->Write(wxT("VersionUpdates/NextCheckTime"), Feature.NextCheckTime.FormatISOCombined(' ')); config->Flush(); } Timer.Start(1000 * 20, wxTIMER_CONTINUOUS); }
void mkmonthr(int y, int m, int jd_flag, struct monthlines *mlines) { struct tm tm; /* for strftime printing local names of * months */ date dt; /* handy date */ int dw; /* width of numbers */ int first; /* first day of month */ int firstm; /* first day of first week of month */ int i, j, k, l; /* just indices */ int last; /* the first day of next month */ int jan1 = 0; /* the first day of this year */ char *ds; /* pointer to day strings (daystr or * jdaystr) */ /* Set name of month. */ memset(&tm, 0, sizeof(tm)); tm.tm_mon = m; wcsftime(mlines->name, sizeof(mlines->name) / sizeof(mlines->name[0]), L"%OB", &tm); mlines->name[0] = towupper(mlines->name[0]); /* * Set first and last to the day number of the first day of this * month and the first day of next month respectively. Set jan1 to * the day number of the first day of this year. */ first = firstday(y, m + 1); if (m == 11) last = firstday(y + 1, 1); else last = firstday(y, m + 2); if (jd_flag) jan1 = firstday(y, 1); /* * Set firstm to the day number of monday of the first week of * this month. (This might be in the last month) */ firstm = first - weekday(first); /* Set ds (daystring) and dw (daywidth) according to the jd_flag. */ if (jd_flag) { ds = jdaystr; dw = 4; } else { ds = daystr; dw = 3; } /* * Fill the lines with day of month or day of year (julian day) * line index: i, each line is one weekday. column index: j, each * column is one day number. print column index: k. */ for (i = 0; i != 7; i++) { l = 0; for (j = firstm + i, k = 0; j < last; j += 7, k += dw) { if (j >= first) { if (jd_flag) dt.d = j - jan1 + 1; else sdater(j, &dt); if (j == highlightdate && !flag_nohighlight && isatty(STDOUT_FILENO)) highlight(mlines->lines[i] + k, ds + dt.d * dw, dw, &l); else memcpy(mlines->lines[i] + k + l, ds + dt.d * dw, dw); } else memcpy(mlines->lines[i] + k + l, " ", dw); } mlines->lines[i][k + l] = '\0'; mlines->extralen[i] = l; } /* fill the weeknumbers. */ if (flag_weeks) { for (j = firstm, k = 0; j < last; k += dw, j += 7) if (j <= nswitch) memset(mlines->weeks + k, ' ', dw); else memcpy(mlines->weeks + k, ds + week(j, &i)*dw, dw); mlines->weeks[k] = '\0'; } }
void Controller::sendDummyWeek(QDate startDate, QDate endDate) { // Sleep( 500 ); std::vector<Dish> dishesVect; dishesVect.push_back( Dish( "Ciorba de varza", "tortilla piept de pui cascaval ardei gras ceapa patrunjel ulei boia usturoi oregano sare", QPixmap(RESOURCES_ROOT"supa3.png"), 1 ) ); dishesVect.push_back( Dish( "Aripioare de pui cu crusta de porumb", "tortilla piept de pui cascaval ardei gras ceapa patrunjel ulei boia usturoi oregano sare", QPixmap(RESOURCES_ROOT"mancare5.png"), 2 ) ); dishesVect.push_back( Dish( "Pastrav pane cu spanac", "tortilla piept de pui cascaval ardei gras ceapa patrunjel ulei boia usturoi oregano sare", QPixmap(RESOURCES_ROOT"mancare1.png"), 2 ) ); dishesVect.push_back( Dish( "Salata din gradina ursului", "tortilla piept de pui cascaval ardei gras ceapa patrunjel ulei boia usturoi oregano sare", QPixmap(RESOURCES_ROOT"salata1.png"), 3 ) ); dishesVect.push_back( Dish( "Salata din gradina bunicii", "tortilla piept de pui cascaval ardei gras ceapa patrunjel ulei boia usturoi oregano sare", QPixmap(RESOURCES_ROOT"salata2.png"), 3 ) ); dishesVect.push_back( Dish( "Supa de ceva fara ceva", "tortilla piept de pui cascaval ardei gras ceapa patrunjel ulei boia usturoi oregano sare", QPixmap(RESOURCES_ROOT"supa4.png"), 1 ) ); dishesVect[0].setNumHappies( rand() % 250 ); dishesVect[1].setNumMeahs( rand() % 250 ); dishesVect[2].setNumWows( rand() % 250 ); dishesVect[3].setNumWows( rand() % 250 ); dishesVect[4].setNumWows( rand() % 250 ); dishesVect[5].setNumWows( rand() % 250 ); // // dishesVect[0].setUserRating( Dish::eHappy ); // dishesVect[1].setUserRating( Dish::eMeah ); // dishesVect[5].setUserRating( Dish::eHappy ); // dishesVect[0].setUserInterest( Dish::EUserInterest( rand() % 4 - 1 ) ); // dishesVect[1].setUserInterest( Dish::EUserInterest( rand() % 4 ) ); // dishesVect[2].setUserInterest( Dish::EUserInterest( rand() % 4 - 1) ); // dishesVect[3].setUserInterest( Dish::EUserInterest( rand() % 4 ) ); // dishesVect[4].setUserInterest( Dish::EUserInterest( rand() % 4 - 1) ); // dishesVect[5].setUserInterest( Dish::EUserInterest( rand() % 4 ) ); std::vector<Day> daysVect; srand(time(0)); randomizeRatings(dishesVect); std::random_shuffle( dishesVect.begin(), dishesVect.end() ); // dishesVect[0].setUserInterest( Dish::EUserInterest( rand() % 4 - 1 ) ); // dishesVect[1].setUserInterest( Dish::EUserInterest( rand() % 4 ) ); // dishesVect[2].setUserInterest( Dish::EUserInterest( rand() % 4 - 1) ); // dishesVect[3].setUserInterest( Dish::EUserInterest( rand() % 4 ) ); // dishesVect[4].setUserInterest( Dish::EUserInterest( rand() % 4 - 1) ); // dishesVect[5].setUserInterest( Dish::EUserInterest( rand() % 4 ) ); daysVect.push_back( Day( "Luni", dishesVect ) ); randomizeRatings(dishesVect); std::random_shuffle( dishesVect.begin(), dishesVect.end() ); // dishesVect[0].setUserInterest( Dish::EUserInterest( rand() % 4 - 1 ) ); // dishesVect[1].setUserInterest( Dish::EUserInterest( rand() % 4 ) ); // dishesVect[2].setUserInterest( Dish::EUserInterest( rand() % 4 - 1) ); // dishesVect[3].setUserInterest( Dish::EUserInterest( rand() % 4 ) ); // dishesVect[4].setUserInterest( Dish::EUserInterest( rand() % 4 - 1) ); // dishesVect[5].setUserInterest( Dish::EUserInterest( rand() % 4 ) ); daysVect.push_back( Day( "Marti", dishesVect ) ); randomizeRatings(dishesVect); std::random_shuffle( dishesVect.begin(), dishesVect.end() ); // dishesVect[0].setUserInterest( Dish::EUserInterest( rand() % 4 - 1 ) ); // dishesVect[1].setUserInterest( Dish::EUserInterest( rand() % 4 ) ); // dishesVect[2].setUserInterest( Dish::EUserInterest( rand() % 4 - 1) ); // dishesVect[3].setUserInterest( Dish::EUserInterest( rand() % 4 ) ); // dishesVect[4].setUserInterest( Dish::EUserInterest( rand() % 4 - 1) ); // dishesVect[5].setUserInterest( Dish::EUserInterest( rand() % 4 ) ); daysVect.push_back( Day( "Miercuri", dishesVect ) ); randomizeRatings(dishesVect); std::random_shuffle( dishesVect.begin(), dishesVect.end() ); // dishesVect[0].setUserInterest( Dish::EUserInterest( rand() % 4 - 1 ) ); // dishesVect[1].setUserInterest( Dish::EUserInterest( rand() % 4 ) ); // dishesVect[2].setUserInterest( Dish::EUserInterest( rand() % 4 - 1) ); // dishesVect[3].setUserInterest( Dish::EUserInterest( rand() % 4 ) ); // dishesVect[4].setUserInterest( Dish::EUserInterest( rand() % 4 - 1) ); // dishesVect[5].setUserInterest( Dish::EUserInterest( rand() % 4 ) ); daysVect.push_back( Day( "Joi", dishesVect ) ); randomizeRatings(dishesVect); std::random_shuffle( dishesVect.begin(), dishesVect.end() ); // dishesVect[0].setUserInterest( Dish::EUserInterest( rand() % 4 - 1 ) ); // dishesVect[1].setUserInterest( Dish::EUserInterest( rand() % 4 ) ); // dishesVect[2].setUserInterest( Dish::EUserInterest( rand() % 4 - 1) ); // dishesVect[3].setUserInterest( Dish::EUserInterest( rand() % 4 ) ); // dishesVect[4].setUserInterest( Dish::EUserInterest( rand() % 4 - 1) ); // dishesVect[5].setUserInterest( Dish::EUserInterest( rand() % 4 ) ); daysVect.push_back( Day( "Vineri", dishesVect ) ); Week week( startDate, endDate, daysVect ); // Show only 2 after and 2 before QDate today = QDate::currentDate(); if( startDate.weekNumber() - today.weekNumber() > 1 ) week.setLastAvailable( true ); else if( startDate.weekNumber() - today.weekNumber() < -1 ) week.setFirstAvailable( true ); emit dataFinished( week ); }
Date & Date::sharpWeek() { sharpDay(); addSecond((1 - week()) * Time::DAY_SECONDS); return *this; }