Lines Matching defs:tms
81 static int validate_tm_struct(struct tm * tms)
85 if (!tms)
88 TM_CHECK(tms->tm_sec < 0 || tms->tm_sec > 60, "second"); /* + Leap sec */
89 TM_CHECK(tms->tm_min < 0 || tms->tm_min > 59, "minute");
90 TM_CHECK(tms->tm_hour < 0 || tms->tm_hour > 23, "hour");
91 TM_CHECK(tms->tm_mday < 1 || tms->tm_mday > 31, "day");
92 TM_CHECK(tms->tm_wday < 0 || tms->tm_wday > 6, "day of week");
93 TM_CHECK(tms->tm_mon < 0 || tms->tm_mon > 11, "month");
94 TM_CHECK(tms->tm_year < 0 || tms->tm_year > 200,"year");
110 struct tm tms;
114 memset(&tms, 0, sizeof(struct tm));
128 tms.tm_sec = bcd2bin(reg[0] & 0x7f);
129 tms.tm_min = bcd2bin(reg[1] & 0x7f);
130 tms.tm_hour = bcd2bin(reg[2] & 0x3f);
133 tms.tm_hour = (tms.tm_hour + 12) % 24;
135 tms.tm_wday = (reg[3] & 0x7) - 1; /* Day of week field is 0..6 */
136 tms.tm_mday = bcd2bin(reg[4] & 0x3f);
137 tms.tm_mon = bcd2bin(reg[5] & 0x1f) - 1; /* Month field is 0..11 */
138 tms.tm_year = ((reg[5] & 0x80) ? 100 : 0) + bcd2bin(reg[6]);
141 if (validate_tm_struct(&tms))
144 time = mktime(&tms);
156 struct tm tms;
162 localtime_r(&time_from_epoch, &tms);
164 if (validate_tm_struct(&tms))
170 reg[0] = bin2bcd(tms.tm_sec);
171 reg[1] = bin2bcd(tms.tm_min);
172 reg[2] = bin2bcd(tms.tm_hour); /* Force 0..23 format even if using AM/PM */
173 reg[3] = bin2bcd(tms.tm_wday + 1);
174 reg[4] = bin2bcd(tms.tm_mday);
175 reg[5] = bin2bcd(tms.tm_mon + 1);
176 if (tms.tm_year >= 100) /* Set century bit*/
180 reg[6] = bin2bcd(tms.tm_year % 100);