week
- The number of
- the week of the year that the day is in. By definition
+ The number of the week of the year that the day is in. By definition
(
ISO 8601), the first week of a year
contains January 4 of that year. (The
ISO-8601
week starts on Monday.) In other words, the first Thursday of
year
- The year field
+ The year field. Keep in mind there is no 0 AD>, so subtracting
+ BC> years from AD> years should be done with care.
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.125 2004/02/25 19:41:23 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.126 2004/03/30 15:53:18 momjian Exp $
*
*-------------------------------------------------------------------------
*/
{"acsst", DTZ, POS(42)}, /* Cent. Australia */
{"acst", DTZ, NEG(16)}, /* Atlantic/Porto Acre Summer Time */
{"act", TZ, NEG(20)}, /* Atlantic/Porto Acre Time */
- {DA_D, ADBC, AD}, /* "ad" for years >= 0 */
+ {DA_D, ADBC, AD}, /* "ad" for years > 0 */
{"adt", DTZ, NEG(12)}, /* Atlantic Daylight Time */
{"aesst", DTZ, POS(44)}, /* E. Australia */
{"aest", TZ, POS(40)}, /* Australia Eastern Std Time */
{"azot", TZ, NEG(4)}, /* Azores Time */
{"azst", DTZ, POS(20)}, /* Azerbaijan Summer Time */
{"azt", TZ, POS(16)}, /* Azerbaijan Time */
- {DB_C, ADBC, BC}, /* "bc" for years < 0 */
+ {DB_C, ADBC, BC}, /* "bc" for years <= 0 */
{"bdst", TZ, POS(8)}, /* British Double Summer Time */
{"bdt", TZ, POS(24)}, /* Dacca */
{"bnt", TZ, POS(32)}, /* Brunei Darussalam Time */
/* -----------------------------------------------------------------------
* formatting.c
*
- * $PostgreSQL: pgsql/src/backend/utils/adt/formatting.c,v 1.72 2004/01/07 18:56:28 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/formatting.c,v 1.73 2004/03/30 15:53:18 momjian Exp $
*
*
* Portions Copyright (c) 1999-2003, PostgreSQL Global Development Group
* AC / DC
* ----------
*/
-#define YEAR_ABS(_y) (_y < 0 ? -(_y -1) : _y)
+#define YEAR_ABS(_y) (_y <= 0 ? -(_y -1) : _y)
#define BC_STR_ORIG " BC"
#define A_D_STR "A.D."
case DCH_B_C:
if (flag == TO_CHAR)
{
- strcpy(inout, (tm->tm_year < 0 ? B_C_STR : A_D_STR));
+ strcpy(inout, (tm->tm_year <= 0 ? B_C_STR : A_D_STR));
return 3;
}
case DCH_BC:
if (flag == TO_CHAR)
{
- strcpy(inout, (tm->tm_year < 0 ? BC_STR : AD_STR));
+ strcpy(inout, (tm->tm_year <= 0 ? BC_STR : AD_STR));
return 1;
}
case DCH_b_c:
if (flag == TO_CHAR)
{
- strcpy(inout, (tm->tm_year < 0 ? b_c_STR : a_d_STR));
+ strcpy(inout, (tm->tm_year <= 0 ? b_c_STR : a_d_STR));
return 3;
}
case DCH_bc:
if (flag == TO_CHAR)
{
- strcpy(inout, (tm->tm_year < 0 ? bc_STR : ad_STR));
+ strcpy(inout, (tm->tm_year <= 0 ? bc_STR : ad_STR));
return 1;
}