*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.204 2009/05/01 19:29:07 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.205 2009/05/26 02:17:50 tgl Exp $
*
*-------------------------------------------------------------------------
*/
/* EncodeDateOnly()
* Encode date as local time.
*/
-int
+void
EncodeDateOnly(struct pg_tm * tm, int style, char *str)
{
- if (tm->tm_mon < 1 || tm->tm_mon > MONTHS_PER_YEAR)
- return -1;
+ Assert(tm->tm_mon >= 1 && tm->tm_mon <= MONTHS_PER_YEAR);
switch (style)
{
sprintf(str + 5, "-%04d %s", -(tm->tm_year - 1), "BC");
break;
}
-
- return TRUE;
-} /* EncodeDateOnly() */
+}
/* EncodeTimeOnly()
* Encode time fields only.
*/
-int
+void
EncodeTimeOnly(struct pg_tm * tm, fsec_t fsec, int *tzp, int style, char *str)
{
- if (tm->tm_hour < 0 || tm->tm_hour > HOURS_PER_DAY)
- return -1;
-
sprintf(str, "%02d:%02d:", tm->tm_hour, tm->tm_min);
str += strlen(str);
if (tzp != NULL)
EncodeTimezone(str, *tzp, style);
-
- return TRUE;
-} /* EncodeTimeOnly() */
+}
/* EncodeDateTime()
* US - mm/dd/yyyy
* European - dd/mm/yyyy
*/
-int
+void
EncodeDateTime(struct pg_tm * tm, fsec_t fsec, int *tzp, char **tzn, int style, char *str)
{
int day;
- /*
- * Why are we checking only the month field? Change this to an assert...
- * if (tm->tm_mon < 1 || tm->tm_mon > MONTHS_PER_YEAR) return -1;
- */
Assert(tm->tm_mon >= 1 && tm->tm_mon <= MONTHS_PER_YEAR);
switch (style)
sprintf(str + strlen(str), " BC");
break;
}
-
- return TRUE;
}
* "year-month literal"s (that look like '2-3') and
* "day-time literal"s (that look like ('4 5:6:7')
*/
-int
+void
EncodeInterval(struct pg_tm * tm, fsec_t fsec, int style, char *str)
{
char *cp = str;
strcat(cp, " ago");
break;
}
-
- return 0;
-} /* EncodeInterval() */
+}
/*
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.198 2009/04/04 04:53:25 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.199 2009/05/26 02:17:50 tgl Exp $
*
*-------------------------------------------------------------------------
*/
if (interval2tm(*span, tm, &fsec) != 0)
elog(ERROR, "could not convert interval to tm");
- if (EncodeInterval(tm, fsec, IntervalStyle, buf) != 0)
- elog(ERROR, "could not format interval");
+ EncodeInterval(tm, fsec, IntervalStyle, buf);
result = pstrdup(buf);
PG_RETURN_CSTRING(result);
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/utils/datetime.h,v 1.72 2009/01/01 17:24:02 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/utils/datetime.h,v 1.73 2009/05/26 02:17:50 tgl Exp $
*
*-------------------------------------------------------------------------
*/
extern int DetermineTimeZoneOffset(struct pg_tm * tm, pg_tz *tzp);
-extern int EncodeDateOnly(struct pg_tm * tm, int style, char *str);
-extern int EncodeTimeOnly(struct pg_tm * tm, fsec_t fsec, int *tzp, int style, char *str);
-extern int EncodeDateTime(struct pg_tm * tm, fsec_t fsec, int *tzp, char **tzn, int style, char *str);
-extern int EncodeInterval(struct pg_tm * tm, fsec_t fsec, int style, char *str);
+extern void EncodeDateOnly(struct pg_tm * tm, int style, char *str);
+extern void EncodeTimeOnly(struct pg_tm * tm, fsec_t fsec, int *tzp, int style, char *str);
+extern void EncodeDateTime(struct pg_tm * tm, fsec_t fsec, int *tzp, char **tzn, int style, char *str);
+extern void EncodeInterval(struct pg_tm * tm, fsec_t fsec, int style, char *str);
extern int DecodeSpecial(int field, char *lowtoken, int *val);
extern int DecodeUnits(int field, char *lowtoken, int *val);