这篇教程C++ weekday函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中weekday函数的典型用法代码示例。如果您正苦于以下问题:C++ weekday函数的具体用法?C++ weekday怎么用?C++ weekday使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了weekday函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: makeTime/*----------------------------------------------------------------------* * Convert the given DST change rule to a time_t value * * for the given year. * *----------------------------------------------------------------------*/time_t Timezone::toTime_t(TimeChangeRule r, int yr){ tmElements_t tm; time_t t; uint8_t m, w; //temp copies of r.month and r.week m = r.month; w = r.week; if (w == 0) { //Last week = 0 if (++m > 12) { //for "Last", go to the next month m = 1; yr++; } w = 1; //and treat as first week of next month, subtract 7 days later } tm.Hour = r.hour; tm.Minute = 0; tm.Second = 0; tm.Day = 1; tm.Month = m; tm.Year = yr - 1970; t = makeTime(tm); //first day of the month, or first day of next month for "Last" rules t += (7 * (w - 1) + (r.dow - weekday(t) + 7) % 7) * SECS_PER_DAY; if (r.week == 0) t -= 7 * SECS_PER_DAY; //back up a week if this is a "Last" rule return t;}
开发者ID:benny0924,项目名称:Timezone,代码行数:31,
示例2: page_addScheduleinline void page_addSchedule() { static schedule s; //Schedule to be added static int value = 0; if(pre_page != ADD_SCHEDULE) { PTLS("Page Add Schedule"); pre_page = ADD_SCHEDULE; lcd.cursor(); //Need to reintialize everytime we enter the page but not every refresh s.day = weekday(); s.hour = hour(); s.minute = minute(); s.temperature = temperature_sensor; value = 0; } String t = getTimeString(s); lcd.print(F("Add: ")); lcd.print(t); lcd.setCursor(0,1); lcd.print(F("Temp: ")); lcd.print(s.temperature); if (button_input == PLUS_UP || button_input == PLUS_HOLD) { if (value == 0) { s.day++; if (s.day >= 8) s.day = 1; } else if (value == 1) { s.hour++; if (s.hour >= 24) s.hour = 0; } else if (value == 2) { s.minute++; if (s.minute >= 60) s.minute = 0; } else if (value == 3) { s.temperature++; if (s.temperature >= 99) s.temperature = 99; } } else if (button_input == MINUS_UP || button_input == MINUS_HOLD) { if (value == 0) { s.day--; if (s.day <= 0) s.day = 7; } else if (value == 1) { s.hour--; if (s.hour >= 24) s.hour = 23; } else if (value == 2) { s.minute--; if (s.minute >= 60) s.minute = 59; } else if (value == 3) { s.temperature--; if (s.temperature <= 32 || s.temperature >= 99) s.temperature = 32; } } else if (button_input == MODE_UP) { value += 1; value = value % 4; } else if (button_input == SET_UP) { node_add(s); switchPage(LIST_MODE); }}
开发者ID:oprospero,项目名称:plug-thermo,代码行数:60,
示例3: date_data_funcstatic void date_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer, GtkTreeModel *model, GtkTreeIter *iter, gpointer data){ int val; struct tm *tm; time_t when; char buffer[40]; gtk_tree_model_get(model, iter, DIVE_DATE, &val, -1); /* 2038 problem */ when = val; tm = gmtime(&when); snprintf(buffer, sizeof(buffer), "%s, %s %d, %d %02d:%02d", weekday(tm->tm_wday), monthname(tm->tm_mon), tm->tm_mday, tm->tm_year + 1900, tm->tm_hour, tm->tm_min); g_object_set(renderer, "text", buffer, NULL);}
开发者ID:johslarsen,项目名称:subsurface,代码行数:25,
示例4: getTimeStringString getTimeString(time_t t = now()){ // String holder to return String dateStr; byte _day = weekday(t); byte sub1 = _day * 3; byte sub2 = sub1 + 3; dateStr = dayShortNames_P.substring(sub1, sub2); //Example "Sun " dateStr.concat(" "); int _hour = hour(t); if(_hour < 10) { dateStr.concat(" "); } dateStr.concat(_hour); // EX: "Sun 10" dateStr.concat(":"); // EX: "Sun 10:" int _minute = minute(t); if(_minute < 10) { dateStr.concat("0"); } dateStr.concat(_minute); // EX: "Sun 10:1" dateStr.concat(":"); // EX: "Sun 10:1:" int _second = second(t); if(_second < 10) { dateStr.concat("0"); } dateStr.concat(_second); // EX: "Sun 10:1:20" return dateStr;}
开发者ID:oprospero,项目名称:plug-thermo,代码行数:34,
示例5: easterodn/* Compute the day number of Easter Sunday in Julian Calendar */static inteasterodn(int y){ /* * Table for the easter limits in one metonic (19-year) cycle. 21 * to 31 is in March, 1 through 18 in April. Easter is the first * sunday after the easter limit. */ int mc[] = {5, 25, 13, 2, 22, 10, 30, 18, 7, 27, 15, 4, 24, 12, 1, 21, 9, 29, 17}; /* Offset from a weekday to next sunday */ int ns[] = {6, 5, 4, 3, 2, 1, 7}; date dt; int dn; /* Assign the easter limit of y to dt */ dt.d = mc[y % 19]; if (dt.d < 21) dt.m = 4; else dt.m = 3; dt.y = y; /* Return the next sunday after the easter limit */ dn = ndaysj(&dt); return (dn + ns[weekday(dn)]);}
开发者ID:FreeBSDFoundation,项目名称:freebsd,代码行数:31,
示例6: show_dive_infovoid show_dive_info(struct dive *dive){ struct tm *tm; const char *text; char buffer[80]; /* dive number and location (or lacking that, the date) go in the window title */ tm = gmtime(&dive->when); text = dive->location; if (!text) text = ""; if (*text) { snprintf(buffer, sizeof(buffer), "Dive #%d - %s", dive->number, text); } else { snprintf(buffer, sizeof(buffer), "Dive #%d - %s %02d/%02d/%04d at %d:%02d", dive->number, weekday(tm->tm_wday), tm->tm_mon+1, tm->tm_mday, tm->tm_year+1900, tm->tm_hour, tm->tm_min); } text = buffer; if (!dive->number) text += 10; /* Skip the "Dive #0 - " part */ gtk_window_set_title(GTK_WINDOW(main_window), text); SET_TEXT_ENTRY(divemaster); SET_TEXT_ENTRY(buddy); SET_TEXT_ENTRY(location); gtk_text_buffer_set_text(notes, dive && dive->notes ? dive->notes : "", -1);}
开发者ID:teni,项目名称:subsurface,代码行数:31,
示例7: weekdayDate::weekday Date::day_of_week() const { // see wikipedia static std::array<const int, 12> const t = { { 0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4 } }; int y=year; int m=month; y -= m < 3; return weekday( (y + y/4 - y/100 + y/400 + t[m-1] + day +6) % 7);}
开发者ID:PeterSommerlad,项目名称:CPlusPlusLecture,代码行数:8,
示例8: mainint main(){ printf("%s/n",weekday(3));// strcpy(week(3),"Fengjie"); //printf("%s/n",week(3)); showweekday(3); return 0;}
开发者ID:cbeigong,项目名称:c,代码行数:9,
示例9: meetup_day_of_monthint meetup_day_of_month(int year, int month, char *descriptor, char *day) { int offset = offset_for_descriptor(descriptor, year, month); int first_weekday = weekday(year, month, offset); int target_weekday = weekday_for_day(day); if (days_in_month(year, month) < offset) return 0; return offset + (target_weekday - first_weekday + 7) % 7;}
开发者ID:ozan,项目名称:solutions,代码行数:9,
示例10: runTimeTodayvoid SchedulerJobInstance::calculateNextRunTime() const { QDateTime nextRun = runTimeToday(); nextRun.setDate(QDate::currentDate().addDays( (weekday() + 1) - QDate::currentDate().dayOfWeek() )); if (nextRun < QDateTime::currentDateTime()) { nextRun = nextRun.addDays(7); } d->nextRunTime = nextRun;}
开发者ID:telldus,项目名称:telldus-live-mobile,代码行数:9,
示例11: loopvoid loop() { delay(250); if (now() != prevDisplay) { // update the display only if time has changed if (timeStatus() != timeNotSet) { DayWeekNumber(year(), month(), day(), weekday()); digitalClockDisplayLCD(); prevDisplay = now(); } }}
开发者ID:RitterRBC,项目名称:Arduino,代码行数:10,
示例12: headers_initvoid headers_init(void){ int i, wd; char *cur_dh = day_headings, *cur_j_dh = j_day_headings; strcpy(day_headings,""); strcpy(j_day_headings,"");#ifdef HAVE_LANGINFO_H# define weekday(wd) nl_langinfo(ABDAY_1+wd)#else# define weekday(wd) _time_info->abbrev_wkday[wd]#endif for(i = 0 ; i < 7 ; i++ ) { ssize_t space_left; wd = (i + weekstart) % 7; if (i) strcat(cur_dh++, " "); space_left = sizeof(day_headings) - (cur_dh - day_headings); if(space_left <= 2) break; cur_dh += center_str(weekday(wd), cur_dh, space_left, 2); if (i) strcat(cur_j_dh++, " "); space_left = sizeof(j_day_headings) - (cur_j_dh - j_day_headings); if(space_left <= 3) break; cur_j_dh += center_str(weekday(wd), cur_j_dh, space_left, 3); }#undef weekday for (i = 0; i < 12; i++) {#ifdef HAVE_LANGINFO_H full_month[i] = nl_langinfo(MON_1+i);#else full_month[i] = _time_info->full_month[i];#endif }}
开发者ID:tcdog001,项目名称:autelan,代码行数:43,
示例13: congesmobstr/* ----------------------------------------------------------------- */int congesmobstr(int jy, char string[])/* ----------------------------------------------------------------- */{int jm,jd; char st[32];double tj,rh,rm,rs;static char *day[7]={"Dim","Lun","Mar","Mer","Jeu","Ven","Sam"};rh=12.0; rm=rs=0.0;easter(jy,&jm,&jd);tj=gregjd(jy,jm,jd,rh,rm,rs)+1.0;jdgreg(tj,&jy,&jm,&jd,&rh,&rm,&rs);sprintf(string,"Paques: %04d.%02d.%02d(%s)",jy,jm,jd,day[weekday(tj)]);tj=gregjd(jy,jm,jd,rh,rm,rs)+38.0;jdgreg(tj,&jy,&jm,&jd,&rh,&rm,&rs);sprintf(st," Ascension: %04d.%02d.%02d(%s)",jy,jm,jd,day[weekday(tj)]); strcat(string,st);tj=gregjd(jy,jm,jd,rh,rm,rs)+11.0;jdgreg(tj,&jy,&jm,&jd,&rh,&rm,&rs);sprintf(st," Pentecote: %04d.%02d.%02d(%s)",jy,jm,jd,day[weekday(tj)]); strcat(string,st);return(0);}
开发者ID:idaohang,项目名称:papergps,代码行数:20,
示例14: ServeEventPagestatic void ServeEventPage(FILE * stream_file){ ServeHeader(stream_file, 200, "OK", false); freeMemory(); const time_t timeNow = nntpTimeServer.LocalNow(); fprintf_P(stream_file, PSTR("<h1>%d Events</h1><h3>%02d:%02d:%02d %d/%d/%d (%d)</h3>"), iNumEvents, hour(timeNow), minute(timeNow), second(timeNow), year(timeNow), month(timeNow), day(timeNow), weekday(timeNow)); for (uint8_t i = 0; i < iNumEvents; i++) fprintf_P(stream_file, PSTR("Event [%02d] Time:%02d:%02d(%d) Command %d data %d,%d<br/>"), i, events[i].time / 60, events[i].time % 60, events[i].time, events[i].command, events[i].data[0], events[i].data[1]);}
开发者ID:egisz,项目名称:sprinklers_pi,代码行数:11,
示例15: now//////////////////////////////////////////////////////////////////////////////////////////////////// check if system date is valid and send the date header.//////////////////////////////////////////////////////////////////////////////////////////////////void ESP8266WebServerEx::sendDateHeader(char* buf) { time_t t = now(); // if time is accurate, then try to send a Date header Wed, 15 Nov 1995 06:25:24 GMT if ( year(t)>2015 ) { char dow[5]; strncpy(dow,dayShortStr(weekday(t)),4); dow[3] = 0; sprintf(buf,"%s, %02u %s %04u %02u:%02u:%02u GMT",dow,day(t),monthShortStr(month(t)),year(t),hour(t),minute(t),second(t)); sendHeader("Date",buf); } }
开发者ID:binhpham1909,项目名称:Arduino,代码行数:14,
示例16: get_dive_date_stringQString get_dive_date_string(timestamp_t when){ struct tm tm; utc_mkdate(when, &tm); return translate("gettextFromC", "%1, %2 %3, %4 %5:%6") .arg(weekday(tm.tm_wday)) .arg(monthname(tm.tm_mon)) .arg(tm.tm_mday) .arg(tm.tm_year + 1900) .arg(tm.tm_hour, 2, 10, QChar('0')) .arg(tm.tm_min, 2, 10, QChar('0'));}
开发者ID:Exhora,项目名称:subsurface,代码行数:12,
示例17: update_dive_infovoid update_dive_info(struct dive *dive){ struct tm *tm; char buffer[80]; char *text; flush_dive_info_changes(); buffered_dive = dive; if (!dive) { gtk_label_set_text(GTK_LABEL(divedate), "no dive"); gtk_label_set_text(GTK_LABEL(divetime), ""); gtk_label_set_text(GTK_LABEL(depth), ""); gtk_label_set_text(GTK_LABEL(duration), ""); return; } tm = gmtime(&dive->when); snprintf(buffer, sizeof(buffer), "%s %02d/%02d/%04d", weekday(tm->tm_wday), tm->tm_mon+1, tm->tm_mday, tm->tm_year+1900); gtk_label_set_text(GTK_LABEL(divedate), buffer); snprintf(buffer, sizeof(buffer), "%02d:%02d:%02d", tm->tm_hour, tm->tm_min, tm->tm_sec); gtk_label_set_text(GTK_LABEL(divetime), buffer); snprintf(buffer, sizeof(buffer), "%d ft", to_feet(dive->maxdepth)); gtk_label_set_text(GTK_LABEL(depth), buffer); snprintf(buffer, sizeof(buffer), "%d min", dive->duration.seconds / 60); gtk_label_set_text(GTK_LABEL(duration), buffer); *buffer = 0; if (dive->watertemp.mkelvin) snprintf(buffer, sizeof(buffer), "%d C", to_C(dive->watertemp)); gtk_label_set_text(GTK_LABEL(temperature), buffer); text = dive->location ? : ""; gtk_entry_set_text(location, text); gtk_label_set_text(GTK_LABEL(locationnote), text); text = dive->notes ? : ""; gtk_text_buffer_set_text(notes, text, -1);}
开发者ID:careychow,项目名称:diveclog,代码行数:53,
示例18: weekday weekday weekday::operator++(int) { const int index = m_index; if (m_index < 7) { ++m_index; } else { m_index = 1; } return weekday(index); }
开发者ID:peelonet,项目名称:peelo-cpp,代码行数:13,
示例19: digitalClockDisplayLCDvoid digitalClockDisplayLCD() { // digital clock display of the time // Serial /w Debug sprintf(buffer, "$FT,Y0,X0#%04d-%02d-%02d ", year(), month(), day()); Serial.print(buffer); sprintf(buffer, "$FT,Y1,X0#%s W%02d D%03d", dow2String(weekday()), WN, DN); Serial.print(buffer); sprintf(buffer, "$Y5,X0#%02d:%02d:", hour(), minute()); Serial.print(buffer); sprintf(buffer, "$FN,Y5,X35#%02d", second()); Serial.print(buffer); Serial.print(F("$FT#")); // I2C LCD LcdSetCursor(0, 0); sprintf(buffer, "%04d-%02d-%02d %s", year(), month(), day(), dow2String(weekday())); LcdPrint(buffer); sprintf(buffer, "%02d:%02d:%02d W%02d %03d", hour(), minute(), second(), WN, DN); LcdSetCursor(0, 1); LcdPrint(buffer);}
开发者ID:RitterRBC,项目名称:Arduino,代码行数:22,
示例20: loopvoid loop(){ // digital clock display of the time sprintf(msg_buff,"%02d:%02d:%02d %s",hour(),minute(),second(), dayStr(weekday())); sprintf(msg_buff,"%s %d %s %d/r/n",msg_buff, day(),monthStr(month()), year()); //Send the data uart_printf(msg_buff); // 1 sec delay delay(1000);}
开发者ID:besmirbytyqi,项目名称:arduino-to-xmc,代码行数:13,
示例21: longStrFormat_Display/** * Display Date and Time with 'hh:mm:ss <CompleteNameDayWeek> dd <CompleteNameMonth> YYYY' format */void longStrFormat_Display(){ timeComplete_Display(); Serial.print(" "); Serial.print(dayStr(weekday())); Serial.print(" "); Serial.print(day()); Serial.print(" "); Serial.print(monthStr(month())); Serial.print(" "); Serial.print(year());}
开发者ID:kiuz,项目名称:Time,代码行数:16,
示例22: makeTimevoid J1ClockKit::Crown::load( tmElements_t &tm ) { this->timeElements.Second = tm.Second; this->timeElements.Minute = tm.Minute; this->timeElements.Hour = tm.Hour; this->timeElements.Day = tm.Day; this->timeElements.Month = tm.Month; this->timeElements.Year = tm.Year; time_t t = makeTime( tm ); this->timeElements.Wday = weekday( t ); this->field = (tmByteFields) min( max( (int)this->field, (int)tmMinute ), (int)tmYear ); this->prepare();}
开发者ID:jun1ro1,项目名称:TinyTimerBin,代码行数:14,
示例23: mainint main(){char * monad = monthName(4);printf("%s", monad); //int leapyear = isLeapYear(1990); //printf("%d", leapyear); //system("pause"); char *svar = weekday(0); printf("%s", svar); system("pause");}
开发者ID:joniz,项目名称:Skolgrejer,代码行数:15,
示例24: dt_gmtime_usEXPORT ER dt_gmtime_us( SYSTIM_U tim_u, struct tm* result ){ SYSTIM_U rem = tim_u; int d, i, md; if (tim_u < 0) { return EX_OVERFLOW; } result->tm_isdst = 0; result->tm_usec = (rem % 1000000); rem /= 1000000; result->tm_sec = (rem % 60); rem /= 60; result->tm_min = (rem % 60); rem /= 60; result->tm_hour = (rem % 24); rem /= 24; d = rem; result->tm_wday = weekday(d); d += daysbefore1985; result->tm_year = -1900 + 1; result->tm_year += 400 * (d / days400); d %= days400; result->tm_year += 100 * (d / days100); d %= days100; result->tm_year += 4 * (d / days4); d %= days4; result->tm_year += (d / days1); d %= days1; result->tm_yday = d; for (i = 0; i < 12; i++) { md = (i == 1 && isleap(result->tm_year)) ? 29 : _dt_mdays[i]; if (d < md) { break; } d -= md; } result->tm_mon = i; result->tm_mday = 1 + d; return E_OK;}
开发者ID:Ninals-GitHub,项目名称:TRON,代码行数:48,
示例25: printTimevoid printTime(time_t t, char *tz) { sPrintI00(hour(t)); sPrintDigits(minute(t)); sPrintDigits(second(t)); Serial.print(' '); Serial.print(weekday(t)); Serial.print(' '); sPrintI00(day(t)); Serial.print(' '); Serial.print(month(t)); Serial.print(' '); Serial.print(year(t)); Serial.print(' '); Serial.print(tz); Serial.println();}
开发者ID:gion86,项目名称:PlantLight,代码行数:16,
示例26: http_response_ok/* HTTP response sending a code 200 OK response.*/void http_response_ok(FILE *resp, char *cont, int size){ struct tm *st; st = get_time(); fprintf(resp, "HTTP/1.1 200 OK/r/n"); fprintf(resp, "Date: %s, %i %s %i %i:%i:%i GMT/r/n", weekday(st->tm_wday), st->tm_mday, month(st->tm_mon), (st->tm_year + 1900), st->tm_hour, st->tm_min, st->tm_sec); fprintf(resp, "Content-Type: %s/r/nContent-Length: %i/r/n/r/n", cont, size); return;}
开发者ID:nni013,项目名称:http-inf2301,代码行数:19,
示例27: monthuint8_t Timer::isSummerTime(){ time_t t = mRtc.get() + TIMEZONE_SHIFT_SECONDS; uint8_t m = month(t); if(m > 10 || m < 3) { return 0; } else if(m > 3 && m < 10) { return 1; } else { uint8_t w = weekday(t); // otestovat posledni nedeli v mesici if(day(t) + 7 - w < 31) { return m == 3 ? 0 : 1; } else { // nedele - otestovat cas if(w == 1) { if(m == 3) { // brezen po druhe hodine return ( hour(t) > 2 ? 1 : 0); } else { // rijen po treti hodine return ( hour(t) > 2 ? 0 : 1); } } else { return m == 3 ? 1 : 0; } } }}
开发者ID:Bhiefer,项目名称:GrowUnit,代码行数:47,
示例28: hourvoid TimeState::renderClockType1(){ Serial.println(F("render time type 1")); _screen->clearDisplay(); _screen->setTextSize(5); _screen->setCursor(0, 0); _screen->setTextWrap(false); int8_t hour_time = hour(); if(hour_time==0) hour_time = (uint8_t) 12; else if(hour_time>=13) hour_time -= (uint8_t) 12; if(hour_time<=9) { _screen->setCursor(30, 0); _screen->print(hour_time); } else _screen->print(hour_time); _screen->setCursor(50, 0); _screen->print(":"); _screen->setCursor(70, 0); int8_t minute_time = minute(); if(minute_time<=9){ _screen->print("0"); _screen->setCursor(99, 0); _screen->print(minute_time); } else _screen->print(minute_time); _screen->setTextSize(2); char *wkdy[7] = {"SUN", "MON", "TUE", "WED", "THR", "FRI", "SAT"}; _screen->setCursor(5, 43); _screen->print(wkdy[weekday()-1]); _screen->setCursor(60, 43); _screen->print(month()); _screen->setCursor(78, 43); _screen->print("/"); _screen->setCursor(95, 43); _screen->print(day()); _screen->display();}
开发者ID:DanielMi7,项目名称:oswatch_arduino_lib,代码行数:47,
注:本文中的weekday函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ weight_sscanf函数代码示例 C++ weechat_string_split函数代码示例 |