Пример #1
0
void update_clock() {
  time_t rawTime;
  struct tm* timeInfo;

  time(&rawTime);
  timeInfo = localtime(&rawTime);

  // DEBUG: use fake time for screenshots
//   if(SCREENSHOT_MODE) {
//     timeInfo->tm_hour = 3;
//     timeInfo->tm_min = 25;
//   }

  int hour = timeInfo->tm_hour;

  if (!clock_is_24h_style()) {
    if(hour > 12) {
      hour %= 12;
    } else if(timeInfo->tm_hour == 0) {
      hour = 12;
    }
  }

  // use the blank image for the leading hour digit if needed
  if(Settings_showLeadingZero || hour / 10 != 0) {
    ClockDigit_setNumber(&clockDigits[0], hour / 10);
  } else {
    ClockDigit_setBlank(&clockDigits[0]);
  }

  ClockDigit_setNumber(&clockDigits[1], hour % 10);
  ClockDigit_setNumber(&clockDigits[2], timeInfo->tm_min  / 10);
  ClockDigit_setNumber(&clockDigits[3], timeInfo->tm_min  % 10);

  // set all the date strings
  strftime(currentDayNum,  3, "%e", timeInfo);
  // strncpy(currentDayName, dayNames[globalSettings.languageId][timeInfo->tm_wday], sizeof(currentDayName));
  // strncpy(currentMonth, monthNames[globalSettings.languageId][timeInfo->tm_mon], sizeof(currentDayName));
  strncpy(currentDayName, dayNames[globalSettings.languageId][timeInfo->tm_wday], sizeof(currentDayName));
  strncpy(currentMonth, monthNames[globalSettings.languageId][timeInfo->tm_mon], sizeof(currentDayName));

  // convert day and month names to uppercase
  for(int i = 0; i < 4; i++) {
    currentDayName[i] = toupper((int)currentDayName[i]);
    currentMonth[i]   = toupper((int)currentMonth[i]);
  }

  // remove padding on date num, if needed
  if(currentDayNum[0] == ' ') {
    currentDayNum[0] = currentDayNum[1];
    currentDayNum[1] = '\0';
  }

  layer_mark_dirty(sidebarLayer);
}
Пример #2
0
void update_clock() {
  time_t rawTime;
  struct tm* timeInfo;

  time(&rawTime);
  timeInfo = localtime(&rawTime);

  // DEBUG: use fake time for screenshots
  // timeInfo->tm_hour = 6;
  // timeInfo->tm_min = 23;

  // debug: set fake condition for screenshots
  // Weather_setConditions(44, false, 44);
  // Weather_weatherInfo.currentTemp = 21;
  // Weather_weatherForecast.highTemp = 22;
  // Weather_weatherForecast.lowTemp = 16;

  int hour = timeInfo->tm_hour;

  if (!clock_is_24h_style()) {
    if(hour > 12) {
      hour %= 12;
    } else if(timeInfo->tm_hour == 0) {
      hour = 12;
    }
  }

  // use the blank image for the leading hour digit if needed
  if(globalSettings.showLeadingZero || hour / 10 != 0) {
    ClockDigit_setNumber(&clockDigits[0], hour / 10, globalSettings.clockFontId);
  } else {
    ClockDigit_setBlank(&clockDigits[0]);
  }

  ClockDigit_setNumber(&clockDigits[1], hour % 10, globalSettings.clockFontId);
  ClockDigit_setNumber(&clockDigits[2], timeInfo->tm_min  / 10, globalSettings.clockFontId);
  ClockDigit_setNumber(&clockDigits[3], timeInfo->tm_min  % 10, globalSettings.clockFontId);

  Sidebar_updateTime(timeInfo);
}