1010import com .ibm .icu .text .MessageFormat ;
1111import com .ibm .icu .text .SimpleDateFormat ;
1212import com .ibm .icu .text .UnicodeSet ;
13+ import com .ibm .icu .util .Calendar ;
1314import com .ibm .icu .util .DateInterval ;
15+ import com .ibm .icu .util .GregorianCalendar ;
1416import com .ibm .icu .util .ICUUncheckedIOException ;
1517import com .ibm .icu .util .Output ;
1618import com .ibm .icu .util .TimeZone ;
2325import java .util .Date ;
2426import java .util .EnumSet ;
2527import java .util .LinkedHashSet ;
28+ import java .util .Locale ;
2629import java .util .Map ;
2730import java .util .Map .Entry ;
2831import java .util .Set ;
@@ -960,11 +963,23 @@ private String getAvailableFormatPath(String skeleton) {
960963 return path ;
961964 }
962965
966+ /**
967+ * @returns a HTML snippet that links to view a specfic XPath
968+ */
963969 public String getFixFromPath (String path ) {
964970 String result = PathHeader .getLinkedView (surveyUrl , file , path );
965971 return result == null ? "" : result ;
966972 }
967973
974+ /**
975+ * @returns HTML snippet that links to view a specific header
976+ */
977+ public String getFixHeaderFromPath (String path ) {
978+ final CLDRConfig config = CLDRConfig .getInstance ();
979+ final PathHeader ph = PathHeader .getFactory (config .getEnglish ()).fromPath (path );
980+ return ph .getLinkedHeaderView (config .urls (), file .getLocaleID ());
981+ }
982+
968983 /**
969984 * Add a table of date comparisons
970985 *
@@ -988,6 +1003,9 @@ public void addDateTable(CLDRFile english, Appendable output) {
9881003 "thu" ,
9891004 "fri" ,
9901005 "sat" );
1006+ output .append ("<h2>" + hackDoubleLinked ("Ordinal Dates" ) + "</h2>\n " );
1007+ addOrdinalDateSubtable (output );
1008+
9911009 output .append ("<h2>" + hackDoubleLinked ("Months" ) + "</h2>\n " );
9921010 addDateSubtable (
9931011 "//ldml/dates/calendars/calendar[@type=\" CALENDAR\" ]/months/monthContext[@type=\" FORMAT\" ]/monthWidth[@type=\" WIDTH\" ]/month[@type=\" TYPE\" ]" ,
@@ -1079,11 +1097,10 @@ private void addDateSubtable(String path, CLDRFile english, Appendable output, S
10791097 }
10801098
10811099 private static final boolean RETIRE = false ;
1082- private static final String LOCALES = ".*" ; // "da|zh|de|ta";
10831100
10841101 /**
1085- * Produce a set of static tables from the vxml data. Only a stopgap until the above is
1086- * integrated into ST .
1102+ * Creates static HTML files in: ../cldr-staging/docs/charts/VERSION/verify/dates these
1103+ * correspond to the Date Time report in the Survey Tool .
10871104 *
10881105 * @param args
10891106 * @throws IOException
@@ -1126,6 +1143,7 @@ public static void main(String[] args) throws IOException {
11261143 }
11271144
11281145 writeCss (DIR );
1146+ System .out .println (String .format ("Writing %d locale(s) to %s" , sorted .size (), DIR ));
11291147 PrintWriter out ;
11301148 // http://st.unicode.org/cldr-apps/survey?_=LOCALE&x=r_datetime&calendar=gregorian
11311149 int oldFirst = 0 ;
@@ -1156,9 +1174,7 @@ public static void main(String[] args) throws IOException {
11561174 + name
11571175 + "</h1>"
11581176 + "<p><a href='index.html'>Index</a></p>\n "
1159- + "<p>The following chart shows typical usage of date and time formatting with the Gregorian calendar and default number system. "
1160- + "<i>There is important information on <a target='CLDR_ST_DOCS' href='http://cldr.unicode.org/translation/date-time-review'>Date/Time Review</a>, "
1161- + "so please read that page before starting!</i></p>\n " );
1177+ + "<p>The following chart shows typical usage of date and time formatting with the Gregorian calendar and default number system.</p>\n " );
11621178 formats .addTable (english , out );
11631179 formats .addDateTable (englishFile , out );
11641180 formats .addDayPeriods (englishFile , out );
@@ -1209,10 +1225,11 @@ public static void writeCss(String directory) throws IOException {
12091225 out .println (
12101226 ".dtf-table, .dtf-int {margin-left:auto; margin-right:auto; border-collapse:collapse;}\n "
12111227 + ".dtf-table, .dtf-s, .dtf-nopad, .dtf-fix, .dtf-th, .dtf-h, .dtf-sep, .dtf-left, .dtf-int {border:1px solid gray;}\n "
1212- + ".dtf-th {background-color:#EEE; padding:4px}\n "
1228+ + ".dtf-th, .dtf-table th {background-color:#EEE; padding:4px}\n "
12131229 + ".dtf-s, .dtf-nopad, .dtf-fix {padding:3px; text-align:center}\n "
12141230 + ".dtf-sep {background-color:#EEF; text-align:center}\n "
12151231 + ".dtf-s {text-align:center;}\n "
1232+ + ".dtf-highlight-cell td:hover {\t background-color:#446e9b;\n \t color:white;\n }\n "
12161233 + ".dtf-int {width:100%; height:100%}\n "
12171234 + ".dtf-fix {width:1px}\n "
12181235 + ".dtf-left {text-align:left;}\n "
@@ -1423,4 +1440,40 @@ static void writeIndexMap(Map<String, String> nameToFile, PrintWriter index) {
14231440 }
14241441 index .println ("</div></body></html>" );
14251442 }
1443+
1444+ void addOrdinalDateSubtable (Appendable output ) throws IOException {
1445+ output .append (
1446+ String .format (
1447+ "<p>%s To fix, see: %s.</p>\n " ,
1448+ "Review this set of 31 dates. For help, see "
1449+ + CLDRURLS .docLink (CLDRURLS .ORDINAL_DATE_HELP , "Help" ),
1450+ getFixHeaderFromPath (
1451+ "//ldml/dates/calendars/calendar[@type=\" generic\" ]/dayOfMonths/dayOfMonthContext[@type=\" format\" ]/dayOfMonthWidth[@type=\" abbreviated\" ]/dayOfMonth[@ordinal=\" other\" ]s" )));
1452+ final String pat = "MMMddd" ; // Jan 4th
1453+ final String patString = generator .getBestPattern (pat );
1454+ final SimpleDateFormat df = icuServiceBuilder .getDateFormat ("gregorian" , patString );
1455+ final SimpleDateFormat detailDf =
1456+ icuServiceBuilderEnglish .getDateFormat ("gregorian" , "E, MMM d" ); // Wed, Mar 4
1457+ df .setTimeZone (TimeZone .getTimeZone ("Europe/Paris" ));
1458+ // we'll use Mar 2026
1459+ output .append ("<table class='dtf-table dtf-highlight-cell'><tbody>\n <tr>\n " );
1460+ Calendar c = new GregorianCalendar (Locale .ENGLISH );
1461+ for (int i = 1 ; i <= 31 ; i ++) {
1462+ c .set (2026 , Calendar .MARCH , i , 12 , 0 , 0 );
1463+ final Date d = c .getTime ();
1464+ String fmt = ICUServiceBuilder .formatWithOrdinalHack (df , "gregorian" , d , file );
1465+ String detailDate =
1466+ ICUServiceBuilder .formatWithOrdinalHack (detailDf , "gregorian" , d , file );
1467+ output .append (
1468+ String .format (
1469+ " <td style='padding: .25em;' title='English: %s'>" ,
1470+ detailDate ))
1471+ .append (fmt )
1472+ .append ("</td>\n " );
1473+ if (i < 31 && i % 7 == 0 ) {
1474+ output .append (" </tr>\n <tr>\n " );
1475+ }
1476+ }
1477+ output .append (" </tr>\n </tbody></table>\n " );
1478+ }
14261479}
0 commit comments