using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Nirvana.Common;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using YBDevice.NApi.Models;

namespace YBDevice.NApi.Controllers
{
    public class HomeController : Controller
    {
        public IActionResult Index()
        {
            return View();
        }

        public IActionResult Privacy()
        {
            return View();
        }

        [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
        public IActionResult Error()
        {
            return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
        }

        public IActionResult testtime(string time= "1612108800")
        {
            var aa = "";
            if (string.IsNullOrEmpty(time)) {
                aa = DateTime.Now.ToString();
            }
            else
            {
                var aas = TimeZoneInfo.Local.Id;
                var ltime = long.Parse(time);
                var dto = DateTimeOffset.FromUnixTimeSeconds(ltime);
                aa = dto.ToLocalTime().DateTime.ToString();
            }
            return Content(aa);
        }
    }
}
