Changeset 3232 in MondoRescue for branches/3.2/mindi-busybox/libbb/time.c
- Timestamp:
- Jan 1, 2014, 12:47:38 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.2/mindi-busybox/libbb/time.c
r2725 r3232 92 92 * Everything but the minutes is optional 93 93 * 94 * This coincides with the format of "touch -t TIME" 94 * "touch -t DATETIME" format: [[[[[YY]YY]MM]DD]hh]mm[.ss] 95 * Some, but not all, Unix "date DATETIME" commands 96 * move [[YY]YY] past minutes mm field (!). 97 * Coreutils date does it, and SUS mandates it. 98 * (date -s DATETIME does not support this format. lovely!) 99 * In bbox, this format is special-cased in date applet 100 * (IOW: this function assumes "touch -t" format). 95 101 */ 102 unsigned cur_year = ptm->tm_year; 96 103 int len = strchrnul(date_str, '.') - date_str; 97 104 … … 134 141 /* Adjust month from 1-12 to 0-11 */ 135 142 ptm->tm_mon -= 1; 143 if ((int)cur_year >= 50) { /* >= 1950 */ 144 /* Adjust year: */ 145 /* 1. Put it in the current century */ 146 ptm->tm_year += (cur_year / 100) * 100; 147 /* 2. If too far in the past, +100 years */ 148 if (ptm->tm_year < cur_year - 50) 149 ptm->tm_year += 100; 150 /* 3. If too far in the future, -100 years */ 151 if (ptm->tm_year > cur_year + 50) 152 ptm->tm_year -= 100; 153 } 136 154 } else 137 155 /* ccyymmddHHMM[.SS] */
Note:
See TracChangeset
for help on using the changeset viewer.