Exemple #1
0
        /// <summary>
        /// Returns the data in this database as a <see cref="TzdbDateTimeZoneSource"/> with no
        /// Windows mappings.
        /// </summary>
        public TzdbDateTimeZoneSource ToTzdbDateTimeZoneSource()
        {
            var ms     = new MemoryStream();
            var writer = new TzdbStreamWriter(ms);

            writer.Write(this, new WindowsZones("n/a", Version, "n/a", new MapZone[0]));
            ms.Position = 0;
            return(TzdbDateTimeZoneSource.FromStream(ms));
        }
Exemple #2
0
 /// <summary>
 /// Returns the data in this database as a <see cref="TzdbDateTimeZoneSource"/> with no
 /// Windows mappings.
 /// </summary>
 public TzdbDateTimeZoneSource ToTzdbDateTimeZoneSource()
 {
     var ms = new MemoryStream();
     var writer = new TzdbStreamWriter();
     writer.Write(this,
         new WindowsZones("n/a", Version, "n/a", new MapZone[0]), // No Windows mappings,
         new Dictionary<string, string>(), // No additional name-to-id mappings
         ms);
     ms.Position = 0;
     return TzdbDateTimeZoneSource.FromStream(ms);
 }
Exemple #3
0
        /// <summary>
        /// Returns the data in this database as a <see cref="TzdbDateTimeZoneSource"/> with no
        /// Windows mappings.
        /// </summary>
        public TzdbDateTimeZoneSource ToTzdbDateTimeZoneSource()
        {
            var ms     = new MemoryStream();
            var writer = new TzdbStreamWriter();

            writer.Write(this,
                         new WindowsZones("n/a", Version, "n/a", new MapZone[0]), // No Windows mappings,
                         new Dictionary <string, string>(),                       // No additional name-to-id mappings
                         ms);
            ms.Position = 0;
            return(TzdbDateTimeZoneSource.FromStream(ms));
        }
Exemple #4
0
        /// <summary>
        /// Runs the compiler from the command line.
        /// </summary>
        /// <param name="arguments">The command line arguments. Each compiler defines its own.</param>
        /// <returns>0 for success, non-0 for error.</returns>
        private static int Main(string[] arguments)
        {
            CompilerOptions options = new CompilerOptions();
            ICommandLineParser parser = new CommandLineParser(new CommandLineParserSettings(Console.Error) { MutuallyExclusive = true });
            if (!parser.ParseArguments(arguments, options))
            {
                return 1;
            }

            var tzdbCompiler = new TzdbZoneInfoCompiler();
            var tzdb = tzdbCompiler.Compile(options.SourceDirectoryName);
            tzdb.LogCounts();
            if (options.ZoneId != null)
            {
                tzdb.GenerateDateTimeZone(options.ZoneId);
                return 0;
            }
            var windowsZones = LoadWindowsZones(options, tzdb.Version);
            if (options.WindowsOverride != null)
            {
                var overrideFile = CldrWindowsZonesParser.Parse(options.WindowsOverride);
                windowsZones = MergeWindowsZones(windowsZones, overrideFile);
            }
            LogWindowsZonesSummary(windowsZones);
            var writer = new TzdbStreamWriter();
            using (var stream = CreateOutputStream(options))
            {
                writer.Write(tzdb, windowsZones, PclSupport.StandardNameToIdMap, stream);
            }

            if (options.OutputFileName != null)
            {
                Console.WriteLine("Reading generated data and validating...");
                var source = Read(options);
                source.Validate();
            }
            return 0;
        }