util.c (8874) | util.c (9554) |
---|---|
1/*- 2 * Copyright (c) 1988, 1993, 1994 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 35 unchanged lines hidden (view full) --- 44#include <string.h> 45#include <time.h> 46#include <tzfile.h> 47#include <unistd.h> 48 49#include "chpass.h" 50#include "pathnames.h" 51 | 1/*- 2 * Copyright (c) 1988, 1993, 1994 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 35 unchanged lines hidden (view full) --- 44#include <string.h> 45#include <time.h> 46#include <tzfile.h> 47#include <unistd.h> 48 49#include "chpass.h" 50#include "pathnames.h" 51 |
52static int dmsize[] = 53 { -1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; | |
54static char *months[] = 55 { "January", "February", "March", "April", "May", "June", 56 "July", "August", "September", "October", "November", 57 "December", NULL }; 58 59char * 60ttoa(tval) 61 time_t tval; --- 47 unchanged lines hidden (view full) --- 109 goto bad; 110 year = atoi(t); 111 if (day < 1 || day > 31 || month < 1 || month > 12 || !year) 112 goto bad; 113 if (year < 100) 114 year += TM_YEAR_BASE; 115 if (year <= EPOCH_YEAR) 116bad: return (1); | 52static char *months[] = 53 { "January", "February", "March", "April", "May", "June", 54 "July", "August", "September", "October", "November", 55 "December", NULL }; 56 57char * 58ttoa(tval) 59 time_t tval; --- 47 unchanged lines hidden (view full) --- 107 goto bad; 108 year = atoi(t); 109 if (day < 1 || day > 31 || month < 1 || month > 12 || !year) 110 goto bad; 111 if (year < 100) 112 year += TM_YEAR_BASE; 113 if (year <= EPOCH_YEAR) 114bad: return (1); |
117 tval = isleap(year) && month > 2; 118 for (--year; year >= EPOCH_YEAR; --year) 119 tval += isleap(year) ? 120 DAYSPERLYEAR : DAYSPERNYEAR; 121 while (--month) 122 tval += dmsize[month]; 123 tval += day; 124 tval = tval * HOURSPERDAY * MINSPERHOUR * SECSPERMIN; 125 tval -= lt->tm_gmtoff; | 115 lt->tm_year = year - TM_YEAR_BASE; 116 lt->tm_mon = month - 1; 117 lt->tm_mday = day; 118 lt->tm_hour = 0; 119 lt->tm_min = 0; 120 lt->tm_sec = 0; 121 lt->tm_isdst = -1; 122 if ((tval = mktime(lt)) < 0) 123 return (1); |
126 *store = tval; 127 return (0); 128} 129 130char * 131ok_shell(name) 132 char *name; 133{ --- 12 unchanged lines hidden --- | 124 *store = tval; 125 return (0); 126} 127 128char * 129ok_shell(name) 130 char *name; 131{ --- 12 unchanged lines hidden --- |