using System;
using UnityEngine;

namespace Wizard;

public class RemainTime
{
	private double _endTime;

	private double _serverUnixTime;

	private float _sinceTime;

	public int Second
	{
		get
		{
			int num = (int)(_endTime - NowUnixTime);
			if (num < 0)
			{
				num = 0;
			}
			return num;
		}
	}

	public double NowUnixTime => _serverUnixTime + (double)Time.realtimeSinceStartup - (double)_sinceTime;

	public DateTime TimeInLocal { get; private set; }

	public string LocalTime { get; private set; }

	public RemainTime()
	{
	}

	public RemainTime(string endTime, double server)
	{
		_sinceTime = Time.realtimeSinceStartup;
		DateTime dateTime = DateTime.Parse(endTime);
		_endTime = ConvertTime.DateTimeToUnixTime(dateTime);
		_serverUnixTime = server;
		LocalTime = ConvertTime.ToLocal(dateTime).ToString();
		TimeInLocal = ConvertTime.ToLocalByDateTime(dateTime);
	}

	public string GetShowText()
	{
		return GetShowText("MyPage_0058", "MyPage_0057", "MyPage_0056");
	}

	public string GetShowText(string minuteId, string hourId, string dayId)
	{
		SystemText systemText = Data.SystemText;
		string text = null;
		if (Second < 3600)
		{
			int num = Second / 60 + 1;
			return systemText.Get(minuteId, num.ToString());
		}
		if (Second < 86400)
		{
			int num2 = Second / 3600;
			return systemText.Get(hourId, num2.ToString());
		}
		int num3 = Second / 86400;
		return systemText.Get(dayId, num3.ToString());
	}
}
