Skip to content

Commit

Permalink
Add test data generator for date time formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
echeran committed Sep 3, 2024
1 parent 2049fef commit 4b136f3
Show file tree
Hide file tree
Showing 3 changed files with 117 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tools/cldr-code/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@
<groupId>com.vdurmont</groupId>
<artifactId>semver4j</artifactId>
</dependency>

<!-- persistent data structures -->
<dependency>
<groupId>org.pcollections</groupId>
<artifactId>pcollections</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
package org.unicode.cldr.tool;

import java.io.IOException;
import java.util.Arrays;
import org.pcollections.HashPMap;
import org.pcollections.HashTreePMap;
import org.pcollections.PMap;
import org.pcollections.PVector;
import org.pcollections.TreePVector;
import org.unicode.cldr.util.CLDRPaths;
import org.unicode.cldr.util.TempPrintWriter;

public class GenerateDateTimeTestData {

private static final String OUTPUT_SUBDIR = "datetime";

private static final String OUTPUT_FILENAME = "datetime.txt";

private static final PVector<String> NUMBERING_SYSTEMS =
TreePVector.from(Arrays.asList("latn", "arab", "beng"));

private static final PVector<String> LOCALES =
TreePVector.from(Arrays.asList("en-US", "en-GB",
"zh-TW", "vi", "ar", "mt-MT",
"bn", "zu",
"und"));

private static final HashPMap<String,Object> emptyMapStringToObject = HashTreePMap.empty();

private static final PVector<PMap<String, Object>> SPEC_OPTIONS =
TreePVector.from(Arrays.asList(
emptyMapStringToObject.plus("dateStyle", "short").plus("timeStyle", "short"),
emptyMapStringToObject.plus("dateStyle", "medium").plus("timeStyle", "medium"),
emptyMapStringToObject.plus("dateStyle", "long").plus("timeStyle", "long"),
emptyMapStringToObject.plus("dateStyle", "full").plus("timeStyle", "full"),
emptyMapStringToObject.plus("dateStyle", "full").plus("timeStyle", "short"),
emptyMapStringToObject.plus("dateStyle", "long"),
emptyMapStringToObject.plus("timeStyle", "long"),
emptyMapStringToObject.plus("hour", "numeric"),
emptyMapStringToObject.plus("hour", "numeric").plus("minute", "numeric"),
emptyMapStringToObject.plus("hour", "numeric").plus("minute", "numeric")
.plus("second", "numeric"),
emptyMapStringToObject.plus("hour", "numeric").plus("minute", "numeric")
.plus("second", "numeric").plus("fractionalSecondDigits", 1),
emptyMapStringToObject.plus("hour", "numeric").plus("minute", "numeric")
.plus("second", "numeric").plus("fractionalSecondDigits", 2),
emptyMapStringToObject.plus("hour", "numeric").plus("minute", "numeric")
.plus("second", "numeric").plus("fractionalSecondDigits", 3),
emptyMapStringToObject.plus("hour", "numeric").plus("minute", "numeric")
.plus("second", "numeric"),
emptyMapStringToObject.plus("month", "numeric").plus("weekday", "long")
.plus("day", "numeric"),
emptyMapStringToObject.plus("month", "2-digit").plus("weekday", "long")
.plus("day", "numeric"),
emptyMapStringToObject.plus("month", "long").plus("weekday", "long").plus("day", "numeric"),
emptyMapStringToObject.plus("month", "short").plus("weekday", "long")
.plus("day", "numeric"),
emptyMapStringToObject.plus("month", "narrow").plus("weekday", "long")
.plus("day", "numeric"),
emptyMapStringToObject.plus("month", "short").plus("weekday", "short")
.plus("day", "numeric"),
emptyMapStringToObject.plus("month", "short").plus("weekday", "narrow")
.plus("day", "numeric"),
emptyMapStringToObject.plus("era", "long"),
emptyMapStringToObject.plus("era", "short"),
emptyMapStringToObject.plus("era", "narrow"),
emptyMapStringToObject.plus("timeZoneName", "long"),
emptyMapStringToObject.plus("timeZoneName", "short"),
emptyMapStringToObject.plus("timeZoneName", "shortOffset"),
emptyMapStringToObject.plus("timeZoneName", "longOffset"),
emptyMapStringToObject.plus("timeZoneName", "shortGeneric"),
emptyMapStringToObject.plus("timeZoneName", "longGeneric")
));

private static final PVector<String> CALENDARS =
TreePVector.from(Arrays.asList(
"gregory",
"buddhist", "hebrew", "chinese", "roc", "japanese",
"islamic", "islamic-umalqura", "persian"
));

private static final PVector<String> TIME_ZONES =
TreePVector.from(Arrays.asList(
"America/Los_Angeles",
"Africa/Luanda",
"Asia/Tehran",
"Europe/Kiev",
"Australia/Brisbane",
"Pacific/Palau",
"America/Montevideo"
));


public static void main(String[] args) throws IOException {
try (TempPrintWriter pw =
TempPrintWriter.openUTF8Writer(
CLDRPaths.TEST_DATA + OUTPUT_SUBDIR, OUTPUT_FILENAME)) {



}
}

}
7 changes: 7 additions & 0 deletions tools/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,13 @@
<artifactId>semver4j</artifactId>
<version>3.1.0</version>
</dependency>

<!-- persistent data structures -->
<dependency>
<groupId>org.pcollections</groupId>
<artifactId>pcollections</artifactId>
<version>2.1.2</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down

0 comments on commit 4b136f3

Please sign in to comment.