mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
- Added some Informix error codes in Informix mode.
- Added just another pgtypeslib function.
This commit is contained in:
@ -19,7 +19,7 @@ main()
|
||||
char *fmt, *out, *in;
|
||||
char *d1 = "Mon Jan 17 1966";
|
||||
char *t1 = "2000-7-12 17:34:29";
|
||||
|
||||
int i;
|
||||
FILE *dbgs;
|
||||
|
||||
if ((dbgs = fopen("log", "w")) != NULL)
|
||||
@ -71,7 +71,7 @@ main()
|
||||
printf("Today in format \"%s\" is \"%s\"\n", fmt, out);
|
||||
free(out);
|
||||
|
||||
/* rdefmtdate() */
|
||||
/* rdate_defmt_asc() */
|
||||
|
||||
date1 = 0; text = "";
|
||||
fmt = "yy/mm/dd";
|
||||
@ -81,78 +81,232 @@ main()
|
||||
*/
|
||||
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
||||
text = PGTYPESdate_to_asc(date1);
|
||||
printf("defmtdate1: %s\n", text);
|
||||
printf("date_defmt_asc1: %s\n", text);
|
||||
|
||||
date1 = 0; text = "";
|
||||
fmt = "mmmm. dd. yyyy";
|
||||
in = "12/25/95";
|
||||
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
||||
text = PGTYPESdate_to_asc(date1);
|
||||
printf("defmtdate2: %s\n", text);
|
||||
printf("date_defmt_asc2: %s\n", text);
|
||||
|
||||
date1 = 0; text = "";
|
||||
fmt = "yy/mm/dd";
|
||||
in = "95/12/25";
|
||||
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
||||
text = PGTYPESdate_to_asc(date1);
|
||||
printf("defmtdate3: %s\n", text);
|
||||
printf("date_defmt_asc3: %s\n", text);
|
||||
|
||||
date1 = 0; text = "";
|
||||
fmt = "yy/mm/dd";
|
||||
in = "1995, December 25th";
|
||||
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
||||
text = PGTYPESdate_to_asc(date1);
|
||||
printf("defmtdate4: %s\n", text);
|
||||
printf("date_defmt_asc4: %s\n", text);
|
||||
|
||||
date1 = 0; text = "";
|
||||
fmt = "dd-mm-yy";
|
||||
in = "This is 25th day of December, 1995";
|
||||
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
||||
text = PGTYPESdate_to_asc(date1);
|
||||
printf("defmtdate5: %s\n", text);
|
||||
printf("date_defmt_asc5: %s\n", text);
|
||||
|
||||
date1 = 0; text = "";
|
||||
fmt = "mmddyy";
|
||||
in = "Dec. 25th, 1995";
|
||||
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
||||
text = PGTYPESdate_to_asc(date1);
|
||||
printf("defmtdate6: %s\n", text);
|
||||
printf("date_defmt_asc6: %s\n", text);
|
||||
|
||||
date1 = 0; text = "";
|
||||
fmt = "mmm. dd. yyyy";
|
||||
in = "dec 25th 1995";
|
||||
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
||||
text = PGTYPESdate_to_asc(date1);
|
||||
printf("defmtdate7: %s\n", text);
|
||||
printf("date_defmt_asc7: %s\n", text);
|
||||
|
||||
date1 = 0; text = "";
|
||||
fmt = "mmm. dd. yyyy";
|
||||
in = "DEC-25-1995";
|
||||
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
||||
text = PGTYPESdate_to_asc(date1);
|
||||
printf("defmtdate8: %s\n", text);
|
||||
printf("date_defmt_asc8: %s\n", text);
|
||||
|
||||
date1 = 0; text = "";
|
||||
fmt = "mm yy dd.";
|
||||
in = "12199525";
|
||||
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
||||
text = PGTYPESdate_to_asc(date1);
|
||||
printf("defmtdate9: %s\n", text);
|
||||
printf("date_defmt_asc9: %s\n", text);
|
||||
|
||||
date1 = 0; text = "";
|
||||
fmt = "yyyy fierj mm dd.";
|
||||
in = "19951225";
|
||||
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
||||
text = PGTYPESdate_to_asc(date1);
|
||||
printf("defmtdate10: %s\n", text);
|
||||
printf("date_defmt_asc10: %s\n", text);
|
||||
|
||||
date1 = 0; text = "";
|
||||
fmt = "mm/dd/yy";
|
||||
in = "122595";
|
||||
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
||||
text = PGTYPESdate_to_asc(date1);
|
||||
printf("defmtdate12: %s\n", text);
|
||||
printf("date_defmt_asc12: %s\n", text);
|
||||
|
||||
PGTYPEStimestamp_current(&ts1);
|
||||
text = PGTYPEStimestamp_to_asc(ts1);
|
||||
printf("timestamp_current: Now: %s\n", text);
|
||||
|
||||
ts1 = PGTYPEStimestamp_from_asc("96-02-29", NULL);
|
||||
text = PGTYPEStimestamp_to_asc(ts1);
|
||||
printf("timestamp_to_asc1: %s\n", text);
|
||||
|
||||
ts1 = PGTYPEStimestamp_from_asc("1994-02-11 3:10:35", NULL);
|
||||
text = PGTYPEStimestamp_to_asc(ts1);
|
||||
printf("timestamp_to_asc2: %s\n", text);
|
||||
|
||||
ts1 = PGTYPEStimestamp_from_asc("1994-02-11 26:10:35", NULL);
|
||||
text = PGTYPEStimestamp_to_asc(ts1);
|
||||
printf("timestamp_to_asc3: %s\n", text);
|
||||
|
||||
/* abc-03:10:35-def-02/11/94-gh */
|
||||
/* 12345678901234567890123456789 */
|
||||
|
||||
out = (char*) malloc(32);
|
||||
i = PGTYPEStimestamp_fmt_asc(&ts1, out, 31, "abc-%X-def-%x-ghi%%");
|
||||
printf("timestamp_fmt_asc: %d: %s\n", i, out);
|
||||
|
||||
fmt = "This is a %m/%d/%y %H-%Ml%Stest";
|
||||
in = "This is a 4/12/80 3-39l12test";
|
||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||
text = PGTYPEStimestamp_to_asc(ts1);
|
||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||
|
||||
fmt = "%a %b %d %H:%M:%S %z %Y";
|
||||
in = "Tue Jul 22 17:28:44 +0200 2003";
|
||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||
text = PGTYPEStimestamp_to_asc(ts1);
|
||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||
|
||||
fmt = "%a %b %d %H:%M:%S %z %Y";
|
||||
in = "Tue Feb 29 17:28:44 +0200 2000";
|
||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||
text = PGTYPEStimestamp_to_asc(ts1);
|
||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||
|
||||
fmt = "%a %b %d %H:%M:%S %z %Y";
|
||||
in = "Tue Feb 29 17:28:44 +0200 1900";
|
||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||
text = PGTYPEStimestamp_to_asc(ts1);
|
||||
printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
|
||||
|
||||
fmt = "%a %b %d %H:%M:%S %z %Y";
|
||||
in = "Tue Feb 29 17:28:44 +0200 1996";
|
||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||
text = PGTYPEStimestamp_to_asc(ts1);
|
||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||
|
||||
fmt = "%b %d %H:%M:%S %z %Y";
|
||||
in = " Jul 31 17:28:44 +0200 1996";
|
||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||
text = PGTYPEStimestamp_to_asc(ts1);
|
||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||
|
||||
fmt = "%b %d %H:%M:%S %z %Y";
|
||||
in = " Jul 32 17:28:44 +0200 1996";
|
||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||
text = PGTYPEStimestamp_to_asc(ts1);
|
||||
printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
|
||||
|
||||
fmt = "%a %b %d %H:%M:%S %z %Y";
|
||||
in = "Tue Feb 29 17:28:44 +0200 1997";
|
||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||
text = PGTYPEStimestamp_to_asc(ts1);
|
||||
printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
|
||||
|
||||
fmt = "%";
|
||||
in = "Tue Jul 22 17:28:44 +0200 2003";
|
||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||
text = PGTYPEStimestamp_to_asc(ts1);
|
||||
printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
|
||||
|
||||
fmt = "a %";
|
||||
in = "Tue Jul 22 17:28:44 +0200 2003";
|
||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||
text = PGTYPEStimestamp_to_asc(ts1);
|
||||
printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
|
||||
|
||||
fmt = "%b, %d %H_%M`%S %z %Y";
|
||||
in = " Jul, 22 17_28 `44 +0200 2003 ";
|
||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||
text = PGTYPEStimestamp_to_asc(ts1);
|
||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||
|
||||
fmt = "%a %b %%%d %H:%M:%S %Z %Y";
|
||||
in = "Tue Jul %22 17:28:44 CEST 2003";
|
||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||
text = PGTYPEStimestamp_to_asc(ts1);
|
||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||
|
||||
fmt = "%a %b %%%d %H:%M:%S %Z %Y";
|
||||
in = "Tue Jul %22 17:28:44 CEST 2003";
|
||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||
text = PGTYPEStimestamp_to_asc(ts1);
|
||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||
|
||||
fmt = "abc%n %C %B %%%d %H:%M:%S %Z %Y";
|
||||
in = "abc\n 19 October %22 17:28:44 CEST 2003";
|
||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||
text = PGTYPEStimestamp_to_asc(ts1);
|
||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||
|
||||
fmt = "abc%n %C %B %%%d %H:%M:%S %Z %y";
|
||||
in = "abc\n 18 October %34 17:28:44 CEST 80";
|
||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||
text = PGTYPEStimestamp_to_asc(ts1);
|
||||
printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
|
||||
|
||||
fmt = "";
|
||||
in = "abc\n 18 October %34 17:28:44 CEST 80";
|
||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||
text = PGTYPEStimestamp_to_asc(ts1);
|
||||
printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
|
||||
|
||||
fmt = NULL;
|
||||
in = "1980-04-12 3:49:44 ";
|
||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||
text = PGTYPEStimestamp_to_asc(ts1);
|
||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||
|
||||
fmt = "%B %d, %Y. Time: %I:%M%p";
|
||||
in = "July 14, 1988. Time: 9:15am";
|
||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||
text = PGTYPEStimestamp_to_asc(ts1);
|
||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||
|
||||
in = "September 6 at 01:30 pm in the year 1983";
|
||||
fmt = "%B %d at %I:%M %p in the year %Y";
|
||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||
text = PGTYPEStimestamp_to_asc(ts1);
|
||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||
|
||||
in = " 1976, July 14. Time: 9:15am";
|
||||
fmt = "%Y, %B %d. Time: %I:%M %p";
|
||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||
text = PGTYPEStimestamp_to_asc(ts1);
|
||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||
|
||||
in = " 1976, July 14. Time: 9:15 am";
|
||||
fmt = "%Y, %B %d. Time: %I:%M%p";
|
||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||
text = PGTYPEStimestamp_to_asc(ts1);
|
||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||
|
||||
in = " 1976, P.M. July 14. Time: 9:15";
|
||||
fmt = "%Y, %P %B %d. Time: %I:%M";
|
||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||
text = PGTYPEStimestamp_to_asc(ts1);
|
||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||
exec sql rollback;
|
||||
exec sql disconnect;
|
||||
|
||||
|
Reference in New Issue
Block a user