C#의 DateTime.IsDaylightSavingTime() 메서드는 이 DateTime 인스턴스가 현재 시간대의 일광 절약 시간제 범위 내에 있는지 여부를 나타내는 데 사용됩니다.
구문
다음은 구문입니다 -
public bool IsDaylightSavingTime ();
예시
이제 DateTime.IsDaylightSavingTime() 메서드를 구현하는 예를 살펴보겠습니다. -
using System;
public class Demo {
public static void Main() {
DateTime d = new DateTime(2019, 10, 11, 7, 10, 40);
bool res = d.IsDaylightSavingTime();
if (res)
Console.WriteLine("TRUE: This instance of DateTime is within the daylight saving time range for the current time zone.");
else
Console.WriteLine("FALSE: This instance of DateTime is within the daylight saving time range for the current time zone.");
}
} 출력
이것은 다음과 같은 출력을 생성합니다 -
FALSE: This instance of DateTime is within the daylight saving time range for the current time zone.
예시
이제 DateTime.IsDaylightSavingTime() 메서드를 구현하는 또 다른 예를 살펴보겠습니다.
using System;
public class Demo {
public static void Main() {
DateTime d = DateTime.Now;
bool res = d.IsDaylightSavingTime();
if (res)
Console.WriteLine("TRUE: This instance of DateTime is within the daylight saving time range for the current time zone.");
else
Console.WriteLine("FALSE: This instance of DateTime is within the daylight saving time range for the current time zone.");
}
} 출력
이것은 다음과 같은 출력을 생성합니다 -
FALSE: This instance of DateTime is within the daylight saving time range for the current time zone.