#include #include int main(argc, argv) int argc; char *argv[]; { int year; char cmd[200], str[200]; if (argc < 2) { printf("Usage %s: MMDDhhmmYY or MMDDhhmmYYYY\n", argv[0]); exit(1); } if (strlen(argv[1]) == 10) { sprintf(cmd, "date %s\n", argv[1]); system(cmd); year = atoi(&argv[1][8]); if (year < 70) { sprintf(cmd, "year %d\n", year + 2000); system(cmd); } system("setrtc"); } else if (strlen(argv[1]) == 12) { strncpy(str, argv[1], 8); str[8] = 0; sprintf(cmd, "date %s\n", str); system(cmd); sprintf(cmd, "year %s\n", &argv[1][8]); system(cmd); system("setrtc"); } else { printf("Usage %s: MMDDhhmmYY or MMDDhhmmYYYY\n", argv[0]); printf("Date must be 10 or 12 characters\n"); exit(1); } return 0; }