36 lines
1002 B
C#
36 lines
1002 B
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using System.Text;
|
||
using System.Threading.Tasks;
|
||
|
||
namespace KssSmaPlaLib.Commons
|
||
{
|
||
public static class DateHelperUxer
|
||
{
|
||
|
||
|
||
/// <summary>
|
||
/// 指定した年と月の末日を返します。
|
||
/// </summary>
|
||
/// <param name="year">年(例: 2025)</param>
|
||
/// <param name="month">月(1~12)</param>
|
||
/// <returns>末日(28~31)</returns>
|
||
public static bool TryGetLastDayOfMonth(int year, int month, out int matsubi,out string resultMessage)
|
||
{
|
||
matsubi = -1;
|
||
resultMessage = string.Empty;
|
||
|
||
if (month < 1 || month > 12)
|
||
{
|
||
resultMessage = "月が1~12の範囲ではありません。";
|
||
return false;
|
||
}
|
||
|
||
// DateTime構造体を使って末日を取得
|
||
matsubi = DateTime.DaysInMonth(year, month);
|
||
return true;
|
||
}
|
||
}
|
||
}
|