java.lang.Object
net.i2p.router.time.Zones

class Zonesextends Object
Country to continent mapping for NTP. Logging is unavailable here: Zones is built from the RouterClock constructor and logging would recurse.
  • Field Details

    • _context

      private final I2PAppContext _context
      The context reading the zone files.
    • _countryToZone

      private final Map<String,String> _countryToZone
      NTP region by lower case country code.
    • _continentToZone

      private final Map<String,String> _continentToZone
      NTP region by upper case continent code.
    • CONTINENT_FILE_DEFAULT

      private static final String CONTINENT_FILE_DEFAULT
      Bundled file mapping continents to NTP regions.
      See Also:
    • ZONES

      private static final String[] ZONES
  • Constructor Details

    • Zones

      public Zones(I2PAppContext ctx)
      Reads in the file in the constructor, so hold onto this.
      Parameters:
      ctx - the app context used to locate the country-to-continent data file
  • Method Details

    • getZone

      public String getZone(String country)
      NTP zone for a country.
      Parameters:
      country - non-null, two letter code, case-independent
      Returns:
      lower-case NTP zone, e.g. "africa", or null
    • readContinentFile

      private void readContinentFile()
      Read in and parse the continent file. The file need not be sorted.

      Format: #comment (# must be in column 1) country code,continent code

      Example: US,NA

      Modified from GeoIP.readCountryFile() ref: NTP zone list