Commit Graph

124 Commits

Author SHA1 Message Date
Bruce Momjian 764122471a Fix to_date()/to_timestamp() 'D' field for day of week, was off by one.
Converting from char using 'D' doesn't make lots of sense, of course.

Report from Brendan Jurd.
2007-02-14 05:10:55 +00:00
Bruce Momjian d1d3f4d015 Add comment that to_char() for broken glibc pt_BR might cause a problem. 2007-02-13 02:00:55 +00:00
Bruce Momjian d7fee591db Remove blank lines in code. 2007-02-09 04:17:58 +00:00
Bruce Momjian acb3416686 Remove blank line from C code. 2007-02-09 03:15:48 +00:00
Bruce Momjian b577aa9ebc Fix bug when localized to_char() day or month names were incorectly
trnasformed to lower or upper string.

Pavel Stehule
2007-02-08 18:19:33 +00:00
Bruce Momjian 9e9e387ecf Fix bug in our code when using to_timestamp() or to_date() without "TM".
Assume "TM" when input fields are variable-length, like month or day
names.  This matches Oracle behavior.
2007-02-08 03:22:28 +00:00
Tom Lane 9a54b76b39 Fix handling of CC (century) format spec in to_date/to_char. According to
standard convention the 21st century runs from 2001-2100, not 2000-2099,
so make it work like that.  Per bug #2885 from Akio Iwaasa.

Backpatch to 8.2, but no further, since this is really a definitional
change; users of older branches are probably more interested in stability.
2007-01-12 23:34:55 +00:00
Bruce Momjian 29dccf5fe0 Update CVS HEAD for 2007 copyright. Back branches are typically not
back-stamped for this.
2007-01-05 22:20:05 +00:00
Peter Eisentraut b64d2d2133 Add workaround for localizing May and abbreviated May differently. Idea
of Dennis Björklund.
2006-11-28 12:53:44 +00:00
Bruce Momjian 9b15b14014 Revert (too late in beta):
Fix to_char() locale handling to honor LC_TIME, not LC_MESSAGES.

Euler Taveira de Oliveira
2006-11-24 22:25:56 +00:00
Bruce Momjian d2b694d825 Fix to_char() locale handling to honor LC_TIME, not LC_MESSAGES.
Euler Taveira de Oliveira
2006-11-24 15:26:18 +00:00
Bruce Momjian f99a569a2e pgindent run for 8.2. 2006-10-04 00:30:14 +00:00
Bruce Momjian 94cf48d72b Back out patch added during 8.2.X development:
Allow to_char() "D" format specifiers for interval/time.

It doesn't work, and I doubt it is useful enough to fix ("D" = day of
week).
2006-09-10 22:54:47 +00:00
Bruce Momjian 1d4abf2175 Fix case where "PM" to_timestamp() mask was eating too many characters.
Report from Josh Tolley.
2006-09-03 01:22:56 +00:00
Bruce Momjian 5d096d0127 Fix problem that sscanf(buf, "%d", &val) eats leading white space, but
our to_* functions were not handling that.
2006-04-19 18:49:09 +00:00
Bruce Momjian e37a649e94 C code whitespace inprovement for formatting.c. 2006-04-19 14:48:06 +00:00
Bruce Momjian f2f5b05655 Update copyright for 2006. Update scripts. 2006-03-05 15:59:11 +00:00
Bruce Momjian 6839bc95d4 Add comment about localized month names for to_date and to_timestamp. 2006-03-03 02:17:30 +00:00
Bruce Momjian 8325be229c Revert because C locale uses "" for thousands_sep, meaning "n/a", while
French uses "" for "don't want".  Seems we have to keep the existing
behavior.
2006-02-12 23:48:23 +00:00
Bruce Momjian 2cb61220eb Support "" for thousands separator and plus sign in to_char(), per
report from French Debian user.  psql already handles "" fine.
2006-02-12 19:52:06 +00:00
Bruce Momjian f695750c43 Allow to_char() to print localized month and day names.
Euler Taveira de Oliveira
2006-02-12 04:44:15 +00:00
Bruce Momjian d20901a39b Allow to_char(interval) and to_char(time) to use AM/PM specifications.
Map them to a single day, so '30 hours' is 'AM'.

Have to_char(interval) and to_char(time) use "HH", "HH12" as 12-hour
intervals, rather than bypass and print the full interval hours.  This
is neeeded because to_char(time) is mapped to interval in this function.
Intervals should use "HH24", and document suggestion.

Allow "D" format specifiers for interval/time.
2005-12-03 16:45:06 +00:00
Bruce Momjian 436a2956d8 Re-run pgindent, fixing a problem where comment lines after a blank
comment line where output as too long, and update typedefs for /lib
directory.  Also fix case where identifiers were used as variable names
in the backend, but as typedefs in ecpg (favor the backend for
indenting).

Backpatch to 8.1.X.
2005-11-22 18:17:34 +00:00
Tom Lane 7218aab7a2 Adjust not-too-sane calculation of DDD value for to_char(interval).
Per gripe from Chris Matheson.
2005-10-20 15:59:46 +00:00
Bruce Momjian 1dc3498251 Standard pgindent run for 8.1. 2005-10-15 02:49:52 +00:00
Bruce Momjian 7be1b3ba74 Add hint for to_char(interval) invalid format specifications. 2005-08-18 13:43:08 +00:00
Bruce Momjian e20261128d Fix to_char(interval) to return proper year and century values.
Fix to_char(interval) to return large year/month/day/hour values that
are larger than possible timestamp values.
Prevent to_char(interval) format specifications that make no sense, like
Month.
Clean up formatting.c code to more logically handle return lengths.
2005-08-18 04:37:08 +00:00
Bruce Momjian 63f850cd4d More formatting.c cleanups. 2005-08-17 22:06:53 +00:00
Bruce Momjian 9cd3fb172d Small cleanup. 2005-08-17 21:54:50 +00:00
Bruce Momjian 420fc28ac5 Adjust to_char/from_char code to use boolean "is_to_char" rather than
integer with flags.
2005-08-17 21:47:55 +00:00
Neil Conway a4c75ece82 Fix a few macro definitions to ensure that unary minus is enclosed in
parentheses. This avoids possible operator precedence problems, and
is consistent with most of the macro definitions in the tree.
2005-07-27 12:44:10 +00:00
Bruce Momjian 3dbbbbf8e9 Andrew pointed out that the current fix didn't handle dates that were
near daylight savings time boudaries.  This handles it properly, e.g.

        test=> select '2005-04-03 04:00:00'::timestamp at time zone
        'America/Los_Angeles';
                timezone
        ------------------------
         2005-04-03 07:00:00-04
        (1 row)
2005-07-23 14:25:34 +00:00
Bruce Momjian a536b2dd80 Add time/date macros for code clarity:
#define DAYS_PER_YEAR   365.25
	#define MONTHS_PER_YEAR 12
	#define DAYS_PER_MONTH  30
	#define HOURS_PER_DAY   24
2005-07-21 03:56:25 +00:00
Bruce Momjian db05f4a7eb Add 'day' field to INTERVAL so 1 day interval can be distinguished from
24 hours. This is very helpful for daylight savings time:

	select '2005-05-03 00:00:00 EST'::timestamp with time zone + '24 hours';
	      ?column?
	----------------------
	2005-05-04 01:00:00-04

	select '2005-05-03 00:00:00 EST'::timestamp with time zone + '1 day';
	      ?column?
	----------------------
	2005-05-04 01:00:00-04

Michael Glaesemann
2005-07-20 16:42:32 +00:00
Neil Conway 76aa6d29cf Code cleanup: remove 3 duplicate static function declarations. 2005-06-24 01:10:11 +00:00
Neil Conway 06ecacded6 More trivial dead code removal: in int_to_roman(), checking for "num == -1"
is redundant after a check has already been made for "num < 0". The "set"
variable can also be removed, as it is now no longer used. Per checking
with Karel, this is the right fix.

Per Coverity static analysis performed by EnterpriseDB.
2005-06-22 01:43:05 +00:00
Bruce Momjian 0851a6fbc7 This patch makes it possible to use the full set of timezones when doing
"AT TIME ZONE", and not just the shorlist previously available. For
example:

SELECT CURRENT_TIMESTAMP AT TIME ZONE 'Europe/London';

works fine now. It will also obey whatever DST rules were in effect at
just that date, which the previous implementation did not.

It also supports the AT TIME ZONE on the timetz datatype. The whole
handling of DST is a bit bogus there, so I chose to make it use whatever
DST rules are in effect at the time of executig the query. not sure if
anybody is actuallyi *using* timetz though, it seems pretty
unpredictable just because of this...

Magnus Hagander
2005-06-15 00:34:11 +00:00
Bruce Momjian b492c3accc Add parentheses to macros when args are used in computations. Without
them, the executation behavior could be unexpected.
2005-05-25 21:40:43 +00:00
Tom Lane fccde77ecb Prevent to_char(interval) from dumping core on month-related formats
when a zero-month interval is given.  Per discussion with Karel.
Also, some desultory const-labeling of constant tables.  More could be
done along that line.
2005-03-26 00:41:31 +00:00
Tom Lane 6e26c00297 Fix to_date to behave reasonably when CC and YY fields are both used.
Karel Zak
2005-03-25 16:08:40 +00:00
Tom Lane cbd8913245 Remove unportable assumption that it's okay to use the target buffer
of an sprintf() as a source string.  Demonstrably does not work with
recent gcc and/or glibc on some platforms.
2005-01-13 01:40:13 +00:00
Bruce Momjian 2daed8c5b3 Update copyrights that were missed. 2005-01-01 05:43:09 +00:00
Tom Lane 83fea34b5b Fix unportable isdigit() call --- must cast arg to unsigned char. 2004-11-20 02:09:47 +00:00
Bruce Momjian 9c3d654a16 Update comment to point to proper file. 2004-11-01 14:33:10 +00:00
Tom Lane 319902dc8c Fix to_number for the case of a trailing S.
Karel Zak
2004-10-28 18:55:08 +00:00
Neil Conway 7069dbcc31 More minor cosmetic improvements:
- remove another senseless "extern" keyword that was applied to a
function definition
- change a foo more function signatures from "some_type foo()" to
"some_type foo(void)"
- rewrite another K&R style function definition
- make the type of the "action" function pointer in the KeyWord struct
in src/backend/utils/adt/formatting.c more precise
2004-10-13 01:25:13 +00:00
Bruce Momjian 15d3f9f6b7 Another pgindent run with lib typedefs added. 2004-08-30 02:54:42 +00:00
Bruce Momjian b6b71b85bc Pgindent run for 8.0. 2004-08-29 05:07:03 +00:00
Bruce Momjian da9a8649d8 Update copyright to 2004. 2004-08-29 04:13:13 +00:00
Tom Lane 63bd0db121 Integrate src/timezone library for all platforms. There is more we can
and should do now that we control our own destiny for timezone handling,
but this commit gets the bulk of the picayune diffs in place.
Magnus Hagander and Tom Lane.
2004-05-21 05:08:06 +00:00