to_date(PG_FUNCTION_ARGS) { text *date_txt = PG_GETARG_TEXT_P(0); text *fmt = PG_GETARG_TEXT_P(1); DateADT result; struct pg_tm tm; fsec_t fsec;
do_to_timestamp(date_txt, fmt, &tm, &fsec); ....
/* * do_to_timestamp: shared code for to_timestamp and to_date
The shared code makes it not immutable:
Further on that reads:
"* Parse the 'date_txt' according to 'fmt', return results as a struct pg_tm
* and fractional seconds."
Which makes it sound like a pure text parsing routine that applies minimal logic to the values that it is parsing. In fact, its doesn't even accept a TZ/OF formatting codes that could be used to determine shift. to_date is always to going to output a date value that reflects the literal input text with "positions" determined by the input format code.
Per Tom Lane [1] while the current implementation is in fact immutable at some point in the future we may wish to add additional environmental logic which will require that it be marked STABLE.