// ************************************************************************** // DiffSec () // // Description: // Called to computer the difference in seconds between this object's // current settings and another. // // Parameters: // CTimeStamp &cts CTimeStamp object to compute difference with. // // Returns: // long - difference = (this - cts) Sec. // ************************************************************************** long CTimeStamp::DiffSec (CTimeStamp &cts) const { long lDiff; int cnDayDiff; // Compute the difference in days: cnDayDiff = m_nDay - cts.m_nDay; // Must account for number of days in a year if years are different: // If our year is less, subtract 365 days, or 366 if a leap year: if (m_st.wYear < cts.m_st.wYear) cnDayDiff -= (ISLEAP (m_st.wYear) ? 366 : 365); // If our year is greater than, add 365 days, or 366 if a leap year: else if (m_st.wYear > cts.m_st.wYear) cnDayDiff += (ISLEAP (cts.m_st.wYear) ? 366 : 365); // Convert difference in days to seconds: lDiff = SECPERDAY * (long)cnDayDiff; // Add difference in time of day (in milliseconds) and convert to seconds: lDiff += ((m_lMS - cts.m_lMS) / 1000L); // Return result: return (lDiff); }
/* ** Given a struct tm representing a calendar time in UTC, convert it to ** seconds since epoch. Returns (time_t) -1 if the time is not ** convertable. Note that this function does not canonicalize the provided ** struct tm, nor does it allow out of range values or years before 1970. */ static time_t mktime_utc (const struct fake_tm *tm) { time_t result = 0; int i; /* We do allow some ill-formed dates, but we don't do anything special * with them and our callers really shouldn't pass them to us. Do * explicitly disallow the ones that would cause invalid array accesses * or other algorithm problems. */ if (tm->tm_mon < 0 || tm->tm_mon > 11 || tm->tm_year < 1970) return (time_t) - 1; /* Convert to a time_t. */ for (i = 1970; i < tm->tm_year; i++) result += 365 + ISLEAP (i); for (i = 0; i < tm->tm_mon; i++) result += MONTHDAYS[i]; if (tm->tm_mon > 1 && ISLEAP (tm->tm_year)) result++; result = 24 * (result + tm->tm_mday - 1) + tm->tm_hour; result = 60 * result + tm->tm_min; result = 60 * result + tm->tm_sec; return result; }
/* This is our own gmtime_r. It differs from its POSIX counterpart in a couple of places, though. */ struct tm *brktimegm(time_t secs, struct tm *tm) { int days, y, ny, m; int md[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; days = secs / 86400; secs %= 86400; tm->tm_hour = secs / 3600; tm->tm_min = (secs % 3600) / 60; tm->tm_sec = secs % 60; /* oh well, may be someone some day will invent a formula for this stuff */ y = 1970; /* start "guessing" */ while (days > 365) { ny = (y + days/366); days -= (ny - y) * 365 + LEAPS_COUNT(ny - 1) - LEAPS_COUNT(y - 1); y = ny; } if (days==365 && !ISLEAP(y)) { days=0; y++; } md[1] = ISLEAP(y)?29:28; for (m=0; days >= md[m]; m++) days -= md[m]; tm->tm_year = y; /* unlike gmtime_r we store complete year here */ tm->tm_mon = m+1; /* unlike gmtime_r tm_mon is from 1 to 12 */ tm->tm_mday = days+1; return tm; }
struct tm *rtc_to_time(uint32_t rtcval, struct tm *res) { /* base decision about std/dst time on current time */ long days = ((int32_t)rtcval) / SECSPERDAY; long rem = ((int32_t)rtcval) % SECSPERDAY; while(rem < 0) { rem += SECSPERDAY; days--; } while(rem >= SECSPERDAY) { rem -= SECSPERDAY; days++; } /* compute hour, min, and sec */ res->tm_hour = (int)(rem / SECSPERHOUR); rem %= SECSPERHOUR; res->tm_min = (int)(rem / 60); res->tm_sec = (int)(rem % 60); /* compute day of week */ if((res->tm_wday = ((EPOCH_WDAY + days) % 7)) < 0) res->tm_wday += 7; /* compute year & day of year */ int y = EPOCH_YEAR; int yleap; if(days >= 0) { while(1) { yleap = ISLEAP(y); if(days < YEAR_LENGTH(yleap)) break; y++; days -= YEAR_LENGTH(yleap); } } else { do { y--; yleap = ISLEAP(y); days += YEAR_LENGTH(yleap); } while (days < 0); } res->tm_year = y - YEAR_BASE; res->tm_yday = days; res->tm_mon = 0; while(days >= MON_LENGTH(yleap, res->tm_mon)) { days -= MON_LENGTH(yleap, res->tm_mon); res->tm_mon++; } res->tm_mday = days + 1; res->tm_isdst = 0; return res; }
int main() { printf("isleap(2014)=%d\n",ISLEAP(2014)); printf("isleap(2000)=%d\n",ISLEAP(2000)); printf("day(2015,2)=%d\n",DAY(2015,2)); printf("day(2000,2)=%d\n",DAY(2000,2)); printf("day(2012,3)=%d\n",DAY(2012,3)); printf("%d\n",(2>1)?(1):(0)); return 0; }
/* Convert epochal time (hours since 00 jan 1, 1970) * to human time (structured) * * Input: * etime = epochal time representation * timeType = time type (e.g., CdChron, CdClim, etc.) as defined in cdms.h * baseYear = base real, used for relative time types only * * Output: htime = human (structured) time representation * * Derived from NRL Neons V3.6 */ void Cde2h(double etime, CdTimeType timeType, long baseYear, CdTime *htime) { long ytemp; /* temporary year holder */ int yr_day_cnt; /* count of days in year */ int doy; /* day of year */ int daysInLeapYear; /* number of days in a leap year */ int daysInYear; /* days in non-leap year */ extern void CdMonthDay(int *doy, CdTime *date); doy = (long) floor(etime / 24.) + 1; htime->hour = etime - (double) (doy - 1) * 24.; /* Correct for goofy floor func on J90 */ if(htime->hour >= 24.){ doy += 1; htime->hour -= 24.; } htime->baseYear = (timeType & CdBase1970) ? 1970 : baseYear; if(!(timeType & CdChronCal)) htime->baseYear = 0; /* Set base year to 0 for Clim */ if(timeType & Cd366) { daysInLeapYear = 366; daysInYear = 366; } else { daysInLeapYear = (timeType & Cd365) ? 366 : 360; daysInYear = (timeType & Cd365) ? 365 : 360; } if (doy > 0) { for (ytemp = htime->baseYear; ; ytemp++) { yr_day_cnt = ISLEAP(ytemp,timeType) ? daysInLeapYear : daysInYear; if (doy <= yr_day_cnt) break; doy -= yr_day_cnt; } } else { for (ytemp = htime->baseYear-1; ; ytemp--) { yr_day_cnt = ISLEAP(ytemp,timeType) ? daysInLeapYear : daysInYear; doy += yr_day_cnt; if (doy > 0) break; } } htime->year = (timeType & CdBase1970) ? ytemp : (ytemp - htime->baseYear); if(!(timeType & CdChronCal)) htime->year = 0; /* Set year to 0 for Clim */ htime->timeType = timeType; CdMonthDay(&doy,htime); return; }
void CdDayOfYear(CdTime *date, int *doy) { int leap_add = 0; /* add 1 day if leap year */ int month; /* month */ long year; month = date->month; if (month < 1 || month > 12) { cdError( "Day-of-year error; month: %d\n", month); month = 1; } if(!(date->timeType & CdChronCal)) /* Ignore year for Clim calendar */ year = 0; else if(!(date->timeType & CdBase1970)) /* year is offset from base for relative time */ year = date->baseYear + date->year; else year = date->year; if (ISLEAP(year,date->timeType) && month > 2) leap_add = 1; if( ((date->timeType) & Cd365) || ((date->timeType) & Cd366) ) { *doy = days_sum[month-1] + date->day + leap_add ; } else { /* date->timeType & Cd360 */ *doy = 30*(month-1) + date->day + leap_add ; } return; }
void CdMonthDay(int *doy, CdTime *date) { int i; /* month counter */ int idoy; /* day of year counter */ long year; if ((idoy = *doy) < 1) { date->month = 0; date->day = 0; return; } if(!(date->timeType & CdChronCal)) /* Ignore year for Clim calendar */ year = 0; else if(!(date->timeType & CdBase1970)) /* year is offset from base for relative time */ year = date->baseYear + date->year; else year = date->year; if (ISLEAP(year,date->timeType)) { mon_day_cnt[1] = 29; } else { mon_day_cnt[1] = 28; } date->month = 0; for (i = 0; i < 12; i++) { (date->month)++; date->day = idoy; if ((idoy -= ((date->timeType & Cd365) ? (mon_day_cnt[date->month-1]) : 30)) <= 0) { return; } } return; }
/*! Get how many days from 2000.1.1 to p_time date \param[in] p_time some time */ static u32 date_to_day(utc_time_t *p_time) { //from BC 1.1.1 u32 year = p_time->year; //here not think leap, but no problem in this system u32 day = (p_time->year - 1) * DAY_PER_YEAR; u32 mon_yday[2][13] = { /* Normal years. */ { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 }, /* Leap years. */ { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 } }; MT_ASSERT(p_time->year != 0); //add leap years day += LEAPS_NUM(year - 1); //add pre-month day day += mon_yday[ISLEAP(year)][p_time->month - 1]; //add current month day day += p_time->day - 1; //day from 1st return day; }
int main(){ int dayNum=0; Data all; all.Year=1; all.Month=1; all.Day=1; while(all.Year!=3001) { buf[all.Year][all.Month][all.Day]=dayNum; all.nextDay(); dayNum++; } int y,n; while(scanf("%d %d",&y,&n)!=EOF&&n>0&&n<367) { int i=1; int j=1; for(i=1;i<13;i++) { for(j=1;j<=dayOfMonth[i][ISLEAP(y)];j++) { if(buf[y][i][j]-buf[y][1][1]+1==n) goto print; } } print:printf("%04d-%02d-%02d\n",y,i,j); } return 0; }
long long countsec(int starty,int year,int mon,int date,int hour,int min,int sec) { int i; long long v=0; for(i=starty; i<year; i++) v+=(365+ISLEAP(i))*24*3600; for(i=0; i<mon-1; i++) v+=DAYS(year,i)*24*3600; return v+(date-1)*24*3600+hour*3600+min*60+sec; }
// ************************************************************************** // IncDay () // // Description: // Increment current settings by specified number of days. // // Parameters: // int nDayInc Number of days to increment by. // // Returns: // void // ************************************************************************** void CTimeStamp::IncDay (int nDayInc) { // Increment the day: m_nDay += nDayInc; // If result is negative, decrement years until positive: if (m_nDay < 0) { while (m_nDay < 0) { // Decrement year: --m_st.wYear; // Add number of day in year (366 if leap year) to // account for decremented year: m_nDay += ISLEAP (m_st.wYear) ? 366 : 365; } } // Else make sure result is less than the number of days in year: else { // Get number of day in current year (366 if leap year) int nDaysPerYear = ISLEAP (m_st.wYear) ? 366 : 365; // If day is beyond end of year, increment year until day of year // is valid: while (m_nDay > nDaysPerYear - 1) { // Subtract number of days in current year: m_nDay -= nDaysPerYear; // Increment year to account for incremented year: ++m_st.wYear; // Get number of days in new year for next test: nDaysPerYear = ISLEAP (m_st.wYear) ? 366 : 365; } } ConvertDateFromDays (); }
void NextDay(){ Day++; if(Day > dayOfMonth[Month][ISLEAP(Year)]){ Day = 1; Month++; if(Month > 12){ Month = 1; Year++; } } }
void util_etoh(struct date_time *dt) { int diy; double secleft; dt->doy = (int) (dt->epoch / 86400.); secleft = mod(dt->epoch,86400.0); dt->hour = 0; dt->minute = 0; dt->second = 0.0; if(secleft) { /* compute hours minutes seconds */ if(secleft < 0) { /* before 1970 */ dt->doy--; /* subtract a day */ secleft += 86400; /* add a day */ } dt->hour = (int) (secleft/3600); secleft = mod(secleft,3600.0); dt->minute = (int) (secleft/60); dt->second = (float) (mod(secleft,60.0)); } if(dt->doy >= 0){ for( dt->year = 1970 ; ; dt->year++ ){ diy = ISLEAP(dt->year) ? 366:365; if( dt->doy < diy ) break; dt->doy -= diy; } } else{ for( dt->year = 1969 ; ; dt->year-- ){ diy = ISLEAP(dt->year) ? 366:365; dt->doy += diy; if( dt->doy >= 0 ) break; } } dt->doy++; dt->date = dt->year * 1000 + dt->doy; util_month_day(dt); return; }
/* Convert human time to epochal time (hours since 00 jan 1, 1970) * * Input: htime = human time representation * * Output: etime = epochal time representation * * Derived from NRL Neons V3.6 */ void Cdh2e(CdTime *htime, double *etime) { long ytemp, year; /* temporary year holder */ int day_cnt; /* count of days */ int doy; /* day of year */ long baseYear; /* base year for epochal time */ int daysInLeapYear; /* number of days in a leap year */ int daysInYear; /* days in non-leap year */ extern void CdDayOfYear(CdTime *date, int *doy); CdDayOfYear(htime,&doy); day_cnt = 0; baseYear = ((htime->timeType) & CdBase1970) ? 1970 : htime->baseYear; year = ((htime->timeType) & CdBase1970) ? htime->year : (htime->year + htime->baseYear); if(!((htime->timeType) & CdChronCal)) baseYear = year = 0; /* set year and baseYear to 0 for Clim */ if((htime->timeType) & Cd366) { daysInLeapYear = 366; daysInYear = 366; } else { daysInLeapYear = ((htime->timeType) & Cd365) ? 366 : 360; daysInYear = ((htime->timeType) & Cd365) ? 365 : 360; } if (year > baseYear) { for (ytemp = year - 1; ytemp >= baseYear; ytemp--) { day_cnt += ISLEAP(ytemp,htime->timeType) ? daysInLeapYear : daysInYear; } } else if (year < baseYear) { for (ytemp = year; ytemp < baseYear; ytemp++) { day_cnt -= ISLEAP(ytemp,htime->timeType) ? daysInLeapYear : daysInYear; } } *etime = (double) (day_cnt + doy - 1) * 24. + htime->hour; return; }
/*! Get how many days current month \param[in] p_time some time */ static u8 get_month_day(utc_time_t *p_time) { //from 2000.1.1 u32 year = p_time->year; u8 mon_lengths[2][12] = { /* Normal years. */ { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }, /* Leap years. */ { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } }; return mon_lengths[ISLEAP(year)][p_time->month - 1]; }
uint32_t rtc_from_time(const struct tm *timp) { int year_abs = timp->tm_year + YEAR_BASE; /* compute hours, minutes, seconds */ int32_t tim = timp->tm_sec + (timp->tm_min * 60) + (timp->tm_hour * SECSPERHOUR); /* compute days in year */ long days = timp->tm_mday - 1 + days_before_month[timp->tm_mon]; if(timp->tm_mon > 1 && ISLEAP(year_abs)) days++; /* compute days in other years */ int year = year_abs; if(year > EPOCH_YEAR) { for(year = EPOCH_YEAR; year < year_abs; year++) days += YEAR_LENGTH(ISLEAP(year)); } else if (year < EPOCH_YEAR) { for(year = EPOCH_YEAR - 1; year >= year_abs; year--) days -= YEAR_LENGTH(ISLEAP(year)); } /* compute total seconds */ tim += (days * SECSPERDAY); return (uint32_t)tim; }
// ************************************************************************** // ConvertDateToDays () // // Description: // Convert date to day of the year. // // Parameters: // none // // Returns: // void // ************************************************************************** void CTimeStamp::ConvertDateToDays () { int nMonth = 0; // Assign number of days in February: anDaysPerMonth [1] = ISLEAP (m_st.wYear) ? 29 : 28; // Save of day of month (zero based): m_nDay = m_st.wDay - 1; // Add number of days in each previous month: while (nMonth < m_st.wMonth - 1) m_nDay += anDaysPerMonth [nMonth++]; }
void util_month_day(struct date_time *dt) { int i,dim,leap; leap = ISLEAP(dt->year); dt->day = dt->doy; for( i = 0 ; i < 12 ; i ++ ){ dim = days_in_month[i]; if( leap && i == 1 ) dim++; if( dt->day <= dim ) break; dt->day -= dim; } dt->month = i + 1; strlcpy(dt->mname,month_name[i], 4); }
/* * initialize from a GMT ctime */ static void create(string gmtime) { string month; int day, hour, minute, second, year; if (sscanf(gmtime, "%*s %s %d %d:%d:%d %d", month, day, hour, minute, second, year) != 7) { error("String not in date format"); } /* count days since start of epoch */ switch (month) { case "Jan": day += JAN1 - 1; break; case "Feb": day += FEB1 - 1; break; case "Mar": day += MAR1 - 1; break; case "Apr": day += APR1 - 1; break; case "May": day += MAY1 - 1; break; case "Jun": day += JUN1 - 1; break; case "Jul": day += JUL1 - 1; break; case "Aug": day += AUG1 - 1; break; case "Sep": day += SEP1 - 1; break; case "Oct": day += OCT1 - 1; break; case "Nov": day += NOV1 - 1; break; case "Dec": day += DEC1 - 1; break; default: error("String not in date format"); } if (!ISLEAP(year) && day > LEAPDAY) { --day; } day += (year - EPOCH_YEAR) * DAYSPERYEAR + LEAPCOUNT(year - 1) - LEAPCOUNT(EPOCH_YEAR - 1); ::create(SECSPERDAY * day + SECSPERHOUR * hour + SECSPERMIN * minute + second); }
// ************************************************************************** // ConvertDateFromDays () // // Description: // Convert day of year to date. // // Parameters: // none // // Returns: // void // ************************************************************************** void CTimeStamp::ConvertDateFromDays () { // Day of year as one based value: int cnDays = m_nDay + 1; // Assign number of days in February anDaysPerMonth [1] = ISLEAP (m_st.wYear) ? 29 : 28; m_st.wMonth = 0; // Subtract number of days in each month until result is less than // the number of days in month. At that point we know what month and // what day of that month date is for: while (cnDays > anDaysPerMonth [m_st.wMonth]) cnDays -= anDaysPerMonth [m_st.wMonth++]; ++m_st.wMonth; // Month is one based m_st.wDay = cnDays; // Date is one based }
int main () { Date n; int *p; int i, count; while (scanf ("%d %d %d", &n.year, &n.month, &n.day) != EOF) { p = ISLEAP (n.year) ? lp : nolp; count = 0; for (i = 1; i < n.month; i++) count += p[i]; count += n.day; printf ("%d\n", count); } return 0; }
// ************************************************************************** // SetDate () // // Description: // Set the date. // // Parameters: /// LPCTSTR lpDate Pointer to string representation of date. Date // format is obtained from system. // bool bInitialize Set to true to initialize member variables. // // Returns: // bool - true if success // ************************************************************************** bool CTimeStamp::SetDate (LPCTSTR lpDate, bool bInitialize) { TCHAR szFmt [32]; int nRetVal; unsigned uMM, uDD, uYYYY; // Create a CSafeLock to make this object thread safe. Our critical // section gets locked here, and will automatically be unlocked when the // CSafeLock goes out of scope. CSafeLock cs (&sm_cs); // Formatting info must be initialized: if (!stDateFmt.nFmtLen) SetDateTimeFormat (); // Create a format string using correct separator charactor: wsprintf (szFmt, _T("%%d%c%%d%c%%d"), *stDateFmt.szSeparator, *stDateFmt.szSeparator); // Extract month, day and year from input string according to system // time format type. _stscanf will return number of fields successfully // extracted from input string: switch (stDateFmt.nFmt) { case VDATE_MMDDYY: nRetVal = _stscanf (lpDate, szFmt, &uMM, &uDD, &uYYYY); break; case VDATE_DDMMYY: nRetVal = _stscanf (lpDate, szFmt, &uDD, &uMM, &uYYYY); break; case VDATE_YYMMDD: nRetVal = _stscanf (lpDate, szFmt, &uYYYY, &uMM, &uDD); break; default: nRetVal = 0; break; } // _stscanf should have extracted 3 fields from input string. If not // return FALSE to indicate error: if (nRetVal != 3) return (FALSE); // Correct year if given as 2 digits: // (If between 90 and 99 assume 19xx. if less than 90 assume 20xx): if (uYYYY < 100) uYYYY += (uYYYY >= 90) ? 1900 : 2000; // Check for valid month: if (uMM < 1 || uMM > 12) return (FALSE); // Make sure day is a not zero: if (uDD < 1) return (FALSE); // Make sure day is not greater than number of days in month: // If February, must account for leap year: if (uMM == 2) { // Use table to check Use ISLEAP macro to adjust for leap year: if (uDD > (unsigned)(anDaysPerMonth [1] + ISLEAP (uYYYY))) return (FALSE); } // If any other month, just use table to check day: else { if (uDD > anDaysPerMonth [uMM - 1]) return (FALSE); } // If we make it here, date is valid so save it: m_st.wYear = uYYYY; m_st.wDay = uDD; m_st.wMonth = uMM; // Convert date to day of year if specified: if (bInitialize) ConvertDateToDays (); // Return TRUE to indicate success: return (TRUE); }
static inline void evt_tadd(utc_time_t *p_time, utc_time_t *p_add) { utc_time_t temp = *p_time; utc_time_t temp1 = {0}; u32 month_day = 0; u32 sec = 0; u8 mon_lengths[2][12] = { /* Normal years. */ { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }, /* Leap years. */ { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } }; sec = UTC_TIME_TO_SEC(p_add); //add second if(sec > 0) { p_time->second = (temp.second + sec) % 60; sec = (temp.second + sec) / 60; //to minute } //add minute if(sec > 0) { p_time->minute = (temp.minute + sec) % 60; sec = (temp.minute + sec) / 60; //to hour } //add hour if(sec > 0) { p_time->hour = (temp.hour + sec) % 24; sec = (temp.hour + sec) / 24; //to day //add_day(p_time, sec); temp1 = *p_time; while(sec > 0) { //month_day = get_month_day(p_time); month_day = mon_lengths[ISLEAP(p_time->year)][p_time->month - 1]; if(temp1.day + sec > month_day) //overrun current month { sec -= (month_day + 1 - temp1.day); //need some day to next month p_time->day = 1; //goto next month. temp1.day = 1; //month plus if(p_time->month < 12) { p_time->month++; } else { p_time->year++; p_time->month = 1; } } else { p_time->day = temp1.day + sec; sec = 0; } } } }
void table_gen(long long nrows, Stringlist wlist,int numcols, int *column_types, double *column_mins, double *column_maxes) { int itemp; int i,j,ii, nwords; int year, month, day, hour, minute, second; int minyear, minmonth, minday; int maxyear, maxmonth, maxday; int leaps[] = LEAPS; int nonleaps[] = NONLEAPS; //printf("Number of rows to be generated: %ld\n",nrows); //exit(0); for (i=0; i<nrows; i++) { for (j=0; j<numcols; j++) { switch (column_types[j]) { case INTEGER: //printf("column_type[%d] = INTEGER\n",j+1); printf("%d",(int)randomrange(column_mins[j],column_maxes[j])); break;; case VARCHAR: //printf("column_type[%d] = VARCHAR\n",j+1); nwords = (int)randomrange(column_mins[j],column_maxes[j]); for (ii=0; ii<nwords ; ii++) { itemp = (int)randomrange(0,wlist.used_size-1); printf("%s",wlist.list[itemp]); if (ii != (nwords-1)) printf(" "); } break;; case TIMESTAMP: //printf("column_type[%d] = TIMESTAMP\n",j+1); minyear = getyear(column_mins[j]); maxyear = getyear(column_maxes[j]); minmonth = getmonth(column_mins[j]); maxmonth = getmonth(column_maxes[j]); minday = getday(column_mins[j]); maxday = getday(column_maxes[j]); year = (int)randomrange(minyear,maxyear); month = (int)randomrange(minmonth,maxmonth); day = (int)randomrange(minday,maxday); if (ISLEAP(year)) { day = MIN(leaps[month-1],day); } else { day = MIN(nonleaps[month-1],day); } hour = (int)randomrange(0,23); minute = (int)randomrange(0,59); second = (int)randomrange(0,59); printf("%.4d-%.2d-%.2d %.2d:%.2d:%.2d",year,month,day,hour,minute,second); break;; case NUMERIC: //printf("column_type[%d] = NUMERIC\n",j+1); printf("%.6f",(float)randomrange(column_mins[j],column_maxes[j])); break;; } if (j != (numcols-1)) printf("|"); } //End of numcolumns printf("\n"); } }