int DecodeInterval(char **, int *, int, int *, struct tm *, fsec_t *);
int DecodeTime(char *, int *, struct tm *, fsec_t *);
-int EncodeDateTime(struct tm *tm, fsec_t fsec, bool print_tz, int tz, const char *tzn, int style, char *str, bool EuroDates);
-int EncodeInterval(struct tm *tm, fsec_t fsec, int style, char *str);
+void EncodeDateTime(struct tm *tm, fsec_t fsec, bool print_tz, int tz, const char *tzn, int style, char *str, bool EuroDates);
+void EncodeInterval(struct tm *tm, fsec_t fsec, int style, char *str);
int tm2timestamp(struct tm *, fsec_t, int *, timestamp *);
int DecodeUnits(int field, char *lowtoken, int *val);
bool CheckDateTokenTables(void);
-int EncodeDateOnly(struct tm *tm, int style, char *str, bool EuroDates);
+void EncodeDateOnly(struct tm *tm, int style, char *str, bool EuroDates);
int GetEpochTime(struct tm *);
int ParseDateTime(char *, char *, char **, int *, int *, char **);
int DecodeDateTime(char **, int *, int, int *, struct tm *, fsec_t *, bool);
/* EncodeDateOnly()
* Encode date as local time.
*/
-int
+void
EncodeDateOnly(struct tm *tm, int style, char *str, bool EuroDates)
{
- 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() */
+}
void
TrimTrailingZeros(char *str)
* US - mm/dd/yyyy
* European - dd/mm/yyyy
*/
-int
+void
EncodeDateTime(struct tm *tm, fsec_t fsec, bool print_tz, int tz, const char *tzn, int style, char *str, bool EuroDates)
{
int day,
}
break;
}
-
- return TRUE;
-} /* EncodeDateTime() */
+}
int
GetEpochTime(struct tm *tm)
* * ECPG semes not to have a global IntervalStyle
* so added
* int IntervalStyle = INTSTYLE_POSTGRES;
- *
- * * Assert wasn't available so removed it.
*/
int
DecodeInterval(char **field, int *ftype, int nf, /* int range, */
* least one digit; there could be ':', '.', '-' embedded in
* it as well.
*/
- /* Assert(*field[i] == '-' || *field[i] == '+'); */
+ Assert(*field[i] == '-' || *field[i] == '+');
/*
* Try for hh:mm or hh:mm:ss. If not, fall through to
* Change pg_tm to tm
*/
-int
+void
EncodeInterval(struct /* pg_ */ tm *tm, fsec_t fsec, int style, char *str)
{
char *cp = str;
strcat(cp, " ago");
break;
}
-
- return 0;
-} /* EncodeInterval() */
+}
/* interval2tm()
return NULL;
}
- if (EncodeInterval(tm, fsec, IntervalStyle, buf) != 0)
- {
- errno = PGTYPES_INTVL_BAD_INTERVAL;
- return NULL;
- }
+ EncodeInterval(tm, fsec, IntervalStyle, buf);
return pgtypes_strdup(buf);
}
/* EncodeSpecialTimestamp()
* * Convert reserved timestamp data type to string.
* */
-static int
+static void
EncodeSpecialTimestamp(timestamp dt, char *str)
{
if (TIMESTAMP_IS_NOBEGIN(dt))
else if (TIMESTAMP_IS_NOEND(dt))
strcpy(str, LATE);
else
- return FALSE;
-
- return TRUE;
-} /* EncodeSpecialTimestamp() */
+ abort(); /* shouldn't happen */
+}
timestamp
PGTYPEStimestamp_from_asc(char *str, char **endptr)