summaryrefslogtreecommitdiff
path: root/contrib/dateformat/test/rand_datetime.c
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2000-01-25 23:53:56 +0000
committerBruce Momjian <bruce@momjian.us>2000-01-25 23:53:56 +0000
commitb866d2e2d79416f8497e4dffa7e800298d018f6c (patch)
treeb633b1415e4b916aaff71d86dc8cee4dba0258e9 /contrib/dateformat/test/rand_datetime.c
parent90aaad06cf25753e10717ac7eb727cd65d8d5726 (diff)
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain: conversion from a datetype to formatted text: to_char( datetime, text) to_char( timestamp, text) to_char( int4, text) to_char( int8, text) to_char( float4, text) to_char( float8, text) to_char( numeric, text) vice versa: to_date ( text, text) to_datetime ( text, text) to_timestamp ( text, text) to_number ( text, text) (convert to numeric) PostgreSQL to_char is very compatible with Oracle's to_char(), but not total exactly (now). Small differentions are in number formating. It will fix in next to_char() version. ! If will this patch aplly to the main tree, must be delete the current to_char version in contrib (directory "dateformat" and note in contrib's README), this patch not erase it (sorry Bruce). The patch patching files: doc/src/sgml/func.sgml ^^^^^^^^ Hmm, I'm not sure if my English... :( Check it anyone (volunteer)? Thomas, it is right? SGML is not my primary lang and compile the current PG docs tree is very happy job (hard variables setting in docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-) What add any definition to global configure.in and set Makefiles in docs tree via ./configure? src/backend/utils/adt/Makefile src/backend/utils/adt/formatting.c src/include/catalog/pg_proc.h src/include/utils/formatting.h Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
Diffstat (limited to 'contrib/dateformat/test/rand_datetime.c')
-rw-r--r--contrib/dateformat/test/rand_datetime.c71
1 files changed, 0 insertions, 71 deletions
diff --git a/contrib/dateformat/test/rand_datetime.c b/contrib/dateformat/test/rand_datetime.c
deleted file mode 100644
index 6a96776b9b7..00000000000
--- a/contrib/dateformat/test/rand_datetime.c
+++ /dev/null
@@ -1,71 +0,0 @@
-
-#include <stdio.h>
-#include <errno.h>
-#include <ctype.h>
-#include <stdlib.h>
-
-
-char *month[] = {
- "Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec",NULL
-};
-
-char *day[] = { "Sun","Mon","Tue","Wed","Thu","Fri","Sat", NULL };
-
-int num(FILE *f, int min, int max)
-{
- int x, y, one;
-
- one = x = fgetc(f);
-
-
- if (x < min)
- x = min;
- else if (x > max) {
- while(x > max)
- x /= 2;
- return x;
- }
-
- do {
- y = fgetc(f);
- if ((x+y) > max)
- return x;
- x += y;
- } while(--one > 0);
-
- return x;
-}
-
-int main(int argc, char **argv)
-{
- FILE *f;
- int count;
-
- if (argc < 5) {
- printf("\nUsage: %s <randfile> <num> <prefix> <postfix>\n", argv[0]);
- printf("\n(C) Karel Zak - Zakkr 1999\n\n");
- exit(1);
- }
-
- if ((f = fopen(argv[1], "r")) == NULL) {
- perror(argv[1]);
- exit(1);
- }
-
- count = atoi(argv[2]);
-
- for(; count > 0; --count) {
- fprintf(stdout, "%s%s %02d %s %02d:%02d:%02d %d%s\n",
- argv[3],
- day[ num(f, 0, 6) ],
- num(f, 1, 28),
- month[ num(f, 0, 11) ],
- num(f, 0, 23),
- num(f, 0, 59),
- num(f, 0, 59),
- num(f, 0, 9999),
- argv[4]
- );
- }
- exit(0);
-} \ No newline at end of file