|
| 1 | +import com.grack.nanojson.JsonObject; |
| 2 | +import com.grack.nanojson.JsonParser; |
| 3 | + |
| 4 | +import java.io.File; |
| 5 | +import java.io.FileInputStream; |
| 6 | +import java.util.Arrays; |
| 7 | +import java.util.Map; |
| 8 | + |
| 9 | +public class CheckAll { |
| 10 | + |
| 11 | + public static void main(String[] args) throws Exception { |
| 12 | + int SECONDS = 59, currentSeconds = 0; |
| 13 | + int MINUTES = 59, currentMinutes = 0; |
| 14 | + int HOURS = 23, currentHours = 0; |
| 15 | + int DAYS = 6, currentDays = 0; |
| 16 | + int WEEKS = 4, currentWeeks = 0; |
| 17 | + int MONTHS = 11, currentMonths = 0; |
| 18 | + int YEARS = 12, currentYears = 0; |
| 19 | + |
| 20 | + for (String name : Arrays.asList("seconds", "minutes", "hours", "days", "weeks", "months", "years")) { |
| 21 | + JsonObject object = JsonParser.object().from(new FileInputStream(new File("timeago-parser/raw/times/" + name + ".json"))); |
| 22 | + |
| 23 | + for (Map.Entry<String, Object> entry : object.entrySet()) { |
| 24 | + JsonObject value = (JsonObject) entry.getValue(); |
| 25 | + |
| 26 | + final int size = value.keySet().size(); |
| 27 | + if (size >= 80) { |
| 28 | + if (name.equals("seconds")) currentSeconds++; |
| 29 | + if (name.equals("minutes")) currentMinutes++; |
| 30 | + if (name.equals("hours")) currentHours++; |
| 31 | + if (name.equals("days")) currentDays++; |
| 32 | + if (name.equals("weeks")) currentWeeks++; |
| 33 | + if (name.equals("months")) currentMonths++; |
| 34 | + if (name.equals("years")) currentYears++; |
| 35 | + } else { |
| 36 | + System.err.println("Missing some units in: " + name + " → " + entry.getKey() + " (current size = " + size + ")"); |
| 37 | + } |
| 38 | + |
| 39 | + String number = entry.getKey().replaceAll("\\D", ""); |
| 40 | + for (Map.Entry<String, Object> langsKeys : value.entrySet()) { |
| 41 | + String lang = langsKeys.getKey(); |
| 42 | + String langValue = String.valueOf(langsKeys.getValue()); |
| 43 | + |
| 44 | + String langValueNumber = langValue.replaceAll("\\D", ""); |
| 45 | + if (!langValueNumber.equals(number)) { |
| 46 | + final String msg = langValueNumber.isEmpty() ? "doesn't contain number" : "different number"; |
| 47 | + System.out.printf("%-20s[!] %22s: %10s = %s \n", entry.getKey(), msg, lang, langValue); |
| 48 | + } |
| 49 | + } |
| 50 | + } |
| 51 | + } |
| 52 | + System.out.println("\n\nHow many:\n"); |
| 53 | + |
| 54 | + if (currentSeconds == SECONDS) System.out.println("seconds: " + currentSeconds); |
| 55 | + else System.out.println("[!] missing seconds: " + currentSeconds); |
| 56 | + |
| 57 | + if (currentMinutes == MINUTES) System.out.println("minutes: " + currentMinutes); |
| 58 | + else System.out.println("[!] missing minutes: " + currentMinutes); |
| 59 | + |
| 60 | + if (currentHours == HOURS) System.out.println("hours: " + currentHours); |
| 61 | + else System.out.println("[!] missing hours: " + currentHours); |
| 62 | + |
| 63 | + if (currentDays == DAYS) System.out.println("days: " + currentDays); |
| 64 | + else System.out.println("[!] missing days: " + currentDays); |
| 65 | + |
| 66 | + if (currentWeeks == WEEKS) System.out.println("weeks: " + currentWeeks); |
| 67 | + else System.out.println("[!] missing weeks: " + currentWeeks); |
| 68 | + |
| 69 | + if (currentMonths == MONTHS) System.out.println("months: " + currentMonths); |
| 70 | + else System.out.println("[!] missing months: " + currentMonths); |
| 71 | + |
| 72 | + if (currentYears == YEARS) System.out.println("years: " + currentYears); |
| 73 | + else System.out.println("[!] missing years: " + currentYears); |
| 74 | + } |
| 75 | +} |
0 commit comments