home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
World_Of_Computer_Software-02-385-Vol-1of3.iso
/
j
/
julian11.zip
/
DATEJFM.C
< prev
next >
Wrap
Text File
|
1993-01-11
|
2KB
|
52 lines
#include "julian.h"
// ===== D A T E _ F M _ J U L
// Is passed a time_t (long) and converts it to a date
//
// dateret_stp - the date string returned
// juldate - the date in julian (long) form
// format_stp - the format that dateret_stp will be returned as
//
int date_fm_jul(char *dateret_stp,time_t juldate, char *format_stp)
{
struct tm *timeptr;
timeptr = localtime(&juldate);
if (strcmp(format_stp,"YY/MM/DD") == 0){
sprintf(dateret_stp,"%02d/%02d/%02d",timeptr->tm_year,
timeptr->tm_mon+1,
timeptr->tm_mday);
}
else if (strcmp(format_stp,"MM/DD/YY") == 0){
sprintf(dateret_stp,"%02d/%02d/%02d",timeptr->tm_mon+1,
timeptr->tm_mday,
timeptr->tm_year);
}
else if (strcmp(format_stp,"YYMMDD") == 0){
sprintf(dateret_stp,"%02d%02d%02d",timeptr->tm_year,
timeptr->tm_mon+1,
timeptr->tm_mday);
}
else if (strcmp(format_stp,"MMDDYY") == 0){
sprintf(dateret_stp,"%02d%02d%02d",timeptr->tm_mon+1,
timeptr->tm_mday,
timeptr->tm_year);
}
else if (strcmp(format_stp,"YYYYMMDD") == 0){
if (timeptr->tm_year < 80)
sprintf(dateret_stp,"%04d%02d02d",timeptr->tm_year+2000,
timeptr->tm_mon+1,
timeptr->tm_mday);
else
sprintf(dateret_stp,"%04d%02d%02d",timeptr->tm_year+1900,
timeptr->tm_mon+1,
timeptr->tm_mday);
}
else{
printf("Invalid date picture.\n");
return(1);
}
return(0);
}