diff options
author | Thomas G. Lockhart <lockhart@fourpalms.org> | 1997-07-01 00:22:46 +0000 |
---|---|---|
committer | Thomas G. Lockhart <lockhart@fourpalms.org> | 1997-07-01 00:22:46 +0000 |
commit | 8507ddb9c63bc341e52c82acf52770ecd423a994 (patch) | |
tree | 3547f66ed836a02a5893019afaf0b912c027e90b /src/backend/utils/adt/datetime.c | |
parent | 43deb7a45f3861e592a9ae325fb9f5e4f290f625 (diff) | |
download | postgresql-8507ddb9c63bc341e52c82acf52770ecd423a994.tar.gz postgresql-8507ddb9c63bc341e52c82acf52770ecd423a994.zip |
Use common parser and encoder for timestamp data type.
Remove older date and time code (retain NEW_DATE_CODE and NEW_TIME_CODE).
Use common encoder for date and time.
Fix datetime +/- timespan math bug.
Diffstat (limited to 'src/backend/utils/adt/datetime.c')
-rw-r--r-- | src/backend/utils/adt/datetime.c | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/src/backend/utils/adt/datetime.c b/src/backend/utils/adt/datetime.c index 9690dd7fe76..2cf7324275b 100644 --- a/src/backend/utils/adt/datetime.c +++ b/src/backend/utils/adt/datetime.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.9 1997/06/23 14:47:26 thomas Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.10 1997/07/01 00:22:40 thomas Exp $ * *------------------------------------------------------------------------- */ @@ -114,15 +114,24 @@ char * date_out(DateADT date) { char *result; + struct tm tt, *tm = &tt; char buf[MAXDATELEN+1]; + +#if FALSE int year, month, day; +#endif - j2date( (date + date2j(2000,1,1)), &year, &month, &day); + j2date( (date + date2j(2000,1,1)), + &(tm->tm_year), &(tm->tm_mon), &(tm->tm_mday)); + EncodeDateOnly( tm, DateStyle, buf); + +#if FALSE if (EuroDates == 1) /* Output European-format dates */ sprintf(buf, "%02d-%02d-%04d", day, month, year); else sprintf(buf, "%02d-%02d-%04d", month, day, year); +#endif result = PALLOC(strlen(buf)+1); @@ -445,19 +454,25 @@ char * time_out(TimeADT *time) { char *result; + struct tm tt, *tm = &tt; +#if FALSE int hour, min, sec; +#endif double fsec; - char buf[32]; + char buf[MAXDATELEN+1]; if (!PointerIsValid(time)) return NULL; - hour = (*time / (60*60)); - min = (((int) (*time / 60)) % 60); - sec = (((int) *time) % 60); + tm->tm_hour = (*time / (60*60)); + tm->tm_min = (((int) (*time / 60)) % 60); + tm->tm_sec = (((int) *time) % 60); fsec = 0; + EncodeTimeOnly( tm, fsec, DateStyle, buf); + +#if FALSE if (sec == 0.0) { sprintf(buf, "%02d:%02d", hour, min); @@ -468,6 +483,7 @@ time_out(TimeADT *time) sprintf(buf, "%02d:%02d:%05.2f", hour, min, (sec+fsec)); }; }; +#endif result = PALLOC(strlen(buf)+1); |