Debian Codegraph @

demo/dateconv.rexx

raw
1 #!/usr/bin/env regina
2 /*
3 * Test program for Regina 08a
4 *
5 * This program tests the new ANSI REXX Date conversion functionality.
6 *
7 */
8 Trace o
9 Say
10 Say 'This is the output from the "normal" Date() function'
11 Say
12 normal_dates = "B D E M N O S U W"
13 Do i = 1 To Words(normal_dates)
14 Call show_dates Word(normal_dates,i)
15 End
16 Say
17 Say 'This is the output from the Date() conversion function'
18 Say
19 Call show_dates 'S','60','D'
20 Call show_dates 'N','03/06/96','E'
21 Call show_dates 'N','06/03/96','U'
22 Call show_dates 'N','96/06/03','O'
23 Call show_dates 'N','19960603','S'
24 Call show_dates 'E','12 Jun 1996','N'
25 Call show_dates 'E','3 Jun 1996','N'
26 Call show_dates 'B','19960603','S'
27 Call show_dates 'B','19960704','S'
28 Call show_dates 'B','00010101','S'
29 Call show_dates 'B','19000101','S'
30 Call show_dates 'B','19890827','S'
31 Call show_dates 'S','726340','B'
32 Call show_dates 'S','0','B'
33 Call show_dates 'S','000','B'
34 Call show_dates 'S','187','D'
35 Call show_dates 'S','1','D'
36 Call show_dates 'S','61','D'
37 Call show_dates 'S','60','D'
38 Call show_dates 'S','59','D'
39 Call show_dates 'S','58','D'
40 Call show_dates 'S','728715','B'
41 Call show_dates 'S','728716','B'
42 Call show_dates 'S','728717','B'
43 Call show_dates 'S','728718','B'
44 Call show_dates 'S','728719','B'
45 Call show_dates 'E','728685','B'
46 Call show_dates 'E','728686','B'
47 Call show_dates 'E','728687','B'
48 Call show_dates 'E','728688','B'
49 Call show_dates 'E','728689','B'
50 Call show_dates 'B','19960228','S'
51 Call show_dates 'B','19960229','S'
52 Call show_dates 'B','19960301','S'
53 Call show_dates 'B','19960302','S'
54 Call show_dates 'E','728905','B'
55 Call show_dates 'W','728905','B'
56 Call show_dates 'W','728906','B'
57 Parse Version ver
58 If Left( ver, 11 ) = 'REXX-Regina' Then
59 Do
60 Say
61 Say 'Regina extensions'
62 Say
63 Call show_dates 'I'
64 Call show_dates 'I', '3 Feb 1996'
65 Call show_dates 'I', '3 Feb 1996', 'N'
66 Call show_dates 'I', '3 Feb 1996', 'N', '/'
67 Say
68 Say 'Regina extensions to allow values for "D" option outside of current year'
69 Say
70 Call show_dates 'S','-3','D'
71 Call show_dates 'S','-2','D'
72 Call show_dates 'S','-1','D'
73 Call show_dates 'S','0','D'
74 Call show_dates 'S','456','D'
75 End
76 Say
77 Say 'Year 2000 (and beyond) specific examples'
78 Say
79 Call show_dates 'N','03/06/99','E'
80 Call show_dates 'N','06/03/99','U'
81 Call show_dates 'N','99/06/03','O'
82 Call show_dates 'N','03/06/00','E'
83 Call show_dates 'N','06/03/00','U'
84 Call show_dates 'N','00/06/03','O'
85 Call show_dates 'N','03/06/01','E'
86 Call show_dates 'N','06/03/01','U'
87 Call show_dates 'N','01/06/03','O'
88 Call show_dates 'S','750000','B'
89 Call show_dates 'B','20540607','S'
90 Call show_dates 'N','25250101','S'
91 Call show_dates 'W','25250101','S'
92
93 Say
94 Say 'Date separator conversion examples'
95 Say
96
97 --Say Left("Date('S','13 Nov 1996','','-')",40) "===>" Date('S','13 Nov 1996','','-')
98 --Say Left("Date('S','13 Nov 1996',,'-')",40) "===>" Date('S','13 Nov 1996',,'-')
99
100 Call show_dates 'S','13 Feb 1996','N', '-'
101 Call show_dates 'N','13 Feb 1996','N', ''
102 Call show_dates 'N','13 Feb 1996','N', '-'
103 Call show_dates 'O','06/01/50','U', ''
104 Call show_dates 'E','02/13/96','U', '.'
105
106 Say Left("Date('N',,,'_')",40) "===>" Date('N',,,'_')
107 Say Left("Date('N','3 Feb 2012',,'_')",40) "===>" Date('N','3 Feb 2012',,'_')
108 Say Left("Date('N',,,'')",40) "===>" Date('N',,,'')
109 Say Left("Date('S','1996-11-13','S','','-')",40) "===>" Date('S','1996-11-13','S','','-')
110 Say Left("Date('S','13-Nov-1996','N','','-')",40) "===>" Date('S','13-Nov-1996','N','','-')
111 Say Left("Date('S','3-Nov-1996','N','','-')",40) "===>" Date('S','3-Nov-1996','N','','-')
112 Say Left("Date('O','06*01*50','U','','*')",40) "===>" Date('O','06*01*50','U','','*')
113 Say Left("Date('U','13.Feb.1996','N',,'.')",40) "===>" Date('U','13.Feb.1996','N',,'.')
114 Say Left("Date('U','13.Feb.1996','N','','.')",40) "===>" Date('U','13.Feb.1996','N','','.')
115 Say Left("Date('U','3.Feb.1996','N','+','.')",40) "===>" Date('U','3.Feb.1996','N','+','.')
116
117 Return 0
118
119 show_dates: Procedure
120 Select
121 When Arg() = 1 Then
122 Say Left("Date('"arg(1)"')",40) "===>" Date(arg(1))
123 When Arg() = 2 Then
124 Say Left("Date('"arg(1)"','"arg(2)"')",40) "===>" Date(arg(1),arg(2))
125 When Arg() = 3 Then
126 Say Left("Date('"arg(1)"','"arg(2)"','"arg(3)"')",40) "===>" Date(arg(1),arg(2),arg(3))
127 When Arg() = 4 Then
128 Say Left("Date('"arg(1)"','"arg(2)"','"arg(3)"','"arg(4)"')",40) "===>" Date(arg(1),arg(2),arg(3),arg(4))
129 When Arg() = 5 Then
130 Say Left("Date('"arg(1)"','"arg(2)"','"arg(3)"','"arg(4)"','"arg(5)"')",40) "===>" Date(arg(1),arg(2),arg(3),arg(4),arg(5))
131 Otherwise Nop
132 End
133 Return