私は jQuery を初めて使用し、すべての検索要求によって、日付/時刻データ型を処理するためのメソッドが表示されます。しかし、分数で指定された一定の期間を処理する必要があります。たとえば、分を無視して、1708
分を式に変換したい。"1 day and 4 hours"
たとえば、C# にはTimeSpan
データ型があり、次のことができます。
public string ConvertMinutes()
{
//Number of minutes I have and want to convert
int n = 1708;
TimeSpan t = new TimeSpan(0, n, 0);
string dayshelper = t.Days == 1 ? "day" : "days";
string hoursHelper = t.Hours == 1 ? "hour" : "hours";
//The result I want to get
//For example "4 days and 2 hours"
string result = string.Empty;
result += t.Days == 0 ? string.Empty : string.Format("{0} {1}", t.Days, dayshelper);
result += t.Hours == 0 ? "." : string.Format(" and {0} {1}.", t.Hours, hoursHelper);
return result;
}
jQueryに似たようなものはありますか? または、自分で分数から日数と時間数を取得する必要がありますか?