Beispiel #1
0
        private static async Task <int> Main(string[] args)
        {
            Options            options = new Options();
            ICommandLineParser parser  = new CommandLineParser(new CommandLineParserSettings(Console.Error));

            if (!parser.ParseArguments(args, options))
            {
                return(1);
            }
            // Not null after we've parsed the arguments.
            TzdbDateTimeZoneSource source = await LoadSourceAsync(options.Source);

            var dumper = new ZoneDumper(source, options);

            try
            {
                using (var writer = options.OutputFile is null ? Console.Out : File.CreateText(options.OutputFile))
                {
                    dumper.Dump(writer);
                }
            }
            catch (UserErrorException e)
            {
                Console.Error.WriteLine($"Error: {e.Message}");
                return(1);
            }

            return(0);
        }
Beispiel #2
0
        private static int Main(string[] args)
        {
            Options options = new Options();
            ICommandLineParser parser = new CommandLineParser(new CommandLineParserSettings(Console.Error) { MutuallyExclusive = true });
            if (!parser.ParseArguments(args, options))
            {
                return 1;
            }
            TzdbDateTimeZoneSource source = LoadSource(options.Source);
            var dumper = new ZoneDumper(source, options);
            try
            {
                using (var writer = options.OutputFile == null ? Console.Out : File.CreateText(options.OutputFile))
                {
                    dumper.Dump(writer);
                }
            }
            catch (UserErrorException e)
            {
                Console.Error.WriteLine($"Error: {e.Message}");
                return 1;
            }

            return 0;
        }        
Beispiel #3
0
        private static int Main(string[] args)
        {
            Options            options = new Options();
            ICommandLineParser parser  = new CommandLineParser(new CommandLineParserSettings(Console.Error)
            {
                MutuallyExclusive = true
            });

            if (!parser.ParseArguments(args, options))
            {
                return(1);
            }
            TzdbDateTimeZoneSource source = LoadSource(options.Source);
            var dumper = new ZoneDumper(source, options);

            try
            {
                using (var writer = options.OutputFile == null ? Console.Out : File.CreateText(options.OutputFile))
                {
                    dumper.Dump(writer);
                }
            }
            catch (UserErrorException e)
            {
                Console.Error.WriteLine($"Error: {e.Message}");
                return(1);
            }

            return(0);
        }
        // This will do something soon :)
        public IActionResult Generate(int startYear = 1, int endYear = 2035)
        {
            var source = TzdbDateTimeZoneSource.Default;
            var writer = new StringWriter();
            var options = new Options { FromYear = startYear, ToYear = endYear };
            var dumper = new ZoneDumper(source, options);
            dumper.Dump(writer);

            return new ContentResult
            {
                Content = writer.ToString(),
                ContentType = "text/plain",
                StatusCode = (int) HttpStatusCode.OK
            };
        }