Example #1
0
        public IActionResult TimeZones(string?version = null, string?format = null)
        {
            var source = TzdbDateTimeZoneSource.Default;

            if (version != null)
            {
                var release = repository.GetRelease($"tzdb{version}.nzd");
                if (release == null)
                {
                    return(BadRequest("Unknown version"));
                }
                source = TzdbDateTimeZoneSource.FromStream(release.GetContent());
            }
            var releaseModel = IanaRelease.FromTzdbDateTimeZoneSource(source);

            if (format == "json")
            {
                return(Json(releaseModel));
            }

            var releases = repository.GetReleases()
                           .Select(release => NzdNamePattern.Match(release.Name))
                           .Where(m => m.Success)
                           .Select(m => m.Groups[1].Value)
                           .ToList();
            var model = (releases, releaseModel);

            return(View(model));
        }
Example #2
0
        public IActionResult Get(string id)
        {
            var release = tzdbRepository.GetRelease(id);

            if (release == null)
            {
                return(NotFound());
            }
            return(File(release.GetContent(), ContentType, release.Name));
        }