xref: /aosp_15_r20/external/pdfium/testing/resources/javascript/util_printd.in (revision 3ac0a46f773bac49fa9476ec2b1cf3f8da5ec3a4)
1{{header}}
2{{object 1 0}} <<
3  /Type /Catalog
4  /Pages 2 0 R
5  /OpenAction 10 0 R
6>>
7endobj
8{{object 2 0}} <<
9  /Type /Pages
10  /Count 1
11  /Kids [
12    3 0 R
13  ]
14>>
15endobj
16% Page number 0.
17{{object 3 0}} <<
18  /Type /Page
19  /Parent 2 0 R
20  /Resources <<
21    /Font <</F1 15 0 R>>
22  >>
23  /Contents [21 0 R]
24  /MediaBox [0 0 612 792]
25>>
26endobj
27% OpenAction action
28{{object 10 0}} <<
29  /Type /Action
30  /S /JavaScript
31  /JS 11 0 R
32>>
33endobj
34% JS program to execute
35{{object 11 0}} <<
36  {{streamlen}}
37>>
38stream
39function TestOneFormat(str, d) {
40  try {
41    app.alert(str + ": " + util.printd(str, d));
42  }
43  catch (e) {
44    app.alert(str + ": Caught error: " + e);
45  }
46}
47function TestOneXFAFormat(str, d, flag) {
48  try {
49    app.alert(str + ": " + util.printd(str, d, flag));
50  }
51  catch (e) {
52    app.alert(str + ": Caught error: " + e);
53  }
54}
55
56// Invalid arguments.
57try {
58  util.printd();
59} catch (e) {
60  app.alert('PASS: ' + e);
61}
62try {
63  util.printd('mm');
64} catch (e) {
65  app.alert('PASS: ' + e);
66}
67try {
68  util.printd('mm', new Date(undefined));
69} catch (e) {
70  app.alert('PASS: ' + e);
71}
72
73// July 4th, 2014 11:59:59 AM local time.
74var d1 = new Date(2014, 06, 04, 15, 59, 58);
75TestOneFormat("mm/dd/yyyy HH:MM:ss", d1);
76TestOneFormat(0, d1);
77TestOneFormat(1, d1);
78TestOneFormat(2, d1);
79TestOneFormat(3, d1);
80TestOneFormat("mmmm", d1);
81TestOneFormat("mmm", d1);
82TestOneFormat("mm", d1);
83TestOneFormat("m", d1);
84TestOneFormat("dddd", d1);
85TestOneFormat("ddd", d1);
86TestOneFormat("dd", d1);
87TestOneFormat("d", d1);
88TestOneFormat("yyyy", d1);
89TestOneFormat("yy", d1);
90TestOneFormat("HH", d1);
91TestOneFormat("H", d1);
92TestOneFormat("hh", d1);
93// "h" is inconsitent between platforms: " 3" vs. "3"
94TestOneFormat("MM", d1);
95TestOneFormat("M", d1);
96TestOneFormat("ss", d1);
97TestOneFormat("s", d1);
98// "tt" is inconsitent between platforms: "PM" vs, "pm" vs. "P"
99TestOneFormat("t", d1);
100TestOneFormat("abc.efg.i.kl.nopqr..uvwxyzABC.EFG.I.KL.NOPQR..UVWXYZ0123456780", d1);
101TestOneFormat("!@#$^&*()-_<>[];:~", d1);
102TestOneFormat("%z %d %%z %%d %%%z %%%d %%% hh:MM", d1);
103TestOneFormat("", d1);
104TestOneFormat("mm/dd/yyyy", d1);
105TestOneFormat("mm/dd/yyyy", new Date(1850, 0, 1));
106TestOneFormat("mm/dd/yyyy", new Date(2525, 11, 31));
107TestOneFormat("mm/dd/yyyy");
108TestOneFormat();
109TestOneFormat("mm/dd/yyyy", 42);
110TestOneFormat("mm/dd/yyyy", "clams");
111TestOneFormat("mm/dd/yyyy", {"clams": 3});
112TestOneFormat("mm/dd/yyyy", ["clams", 3]);
113TestOneFormat({"clams": 3}, d1);
114TestOneFormat(["clams", 3], d1);
115TestOneXFAFormat("mm", d1, false);
116TestOneXFAFormat("mm", d1, true);
117
118// Date with year 0.
119// TODO(thestig): Why is the output different from Acrobat?
120TestOneFormat("mm/dd/yyyy HH:MM:ss", new Date(0, 06, 04, 15, 59, 58));
121// Date with month 20.
122TestOneFormat("mm/dd/yyyy HH:MM:ss", new Date(2014, 20, 04, 15, 59, 58));
123// Date with day 100.
124TestOneFormat("mm/dd/yyyy HH:MM:ss", new Date(2014, 20, 100, 15, 59, 58));
125// Date with hour 50
126TestOneFormat("mm/dd/yyyy HH:MM:ss", new Date(2014, 06, 04, 50, 59, 58));
127// Date with minute 1234.
128TestOneFormat("mm/dd/yyyy HH:MM:ss", new Date(2014, 06, 04, 15, 1234, 58));
129// Date with second 65.
130TestOneFormat("mm/dd/yyyy HH:MM:ss", new Date(2014, 06, 04, 15, 59, 65));
131// Date with April 31th.
132TestOneFormat("mm/dd/yyyy HH:MM:ss", new Date(2014, 03, 31, 15, 59, 58));
133// Date with February 30th.
134TestOneFormat("mm/dd/yyyy HH:MM:ss", new Date(2014, 01, 30, 15, 59, 58));
135// Date with negative year.
136// Acrobat prints out "07/04/-001 15:59:58" but handling this rarely used case
137// outside of FXSYS_wcsftime() is a lot of work.
138TestOneFormat("mm/dd/yyyy HH:MM:ss", new Date(-1, 06, 04, 15, 59, 58));
139// Date with negative month.
140TestOneFormat("mm/dd/yyyy HH:MM:ss", new Date(2014, -1, 30, 15, 59, 58));
141// Date with negative day.
142TestOneFormat("mm/dd/yyyy HH:MM:ss", new Date(2014, 06, -1, 15, 59, 58));
143// Date with negative hour.
144TestOneFormat("mm/dd/yyyy HH:MM:ss", new Date(2014, 06, 04, -1, 59, 58));
145// Date with negative minute.
146TestOneFormat("mm/dd/yyyy HH:MM:ss", new Date(2014, 06, 04, 15, -1, 58));
147// Date with negative second.
148TestOneFormat("mm/dd/yyyy HH:MM:ss", new Date(2014, 06, 04, 15, 59, -1));
149endstream
150endobj
151{{xref}}
152{{trailer}}
153{{startxref}}
154%%EOF
155