namespace SharedKernel.Extensions { public static class DateTimeExtension { // 날짜 포맷 조회 public static string GetDateAt(this DateTime dateTime, string format = "yyyy.MM.dd HH:mm:ss") => dateTime.ToLocalTime().ToString(format); public static string? GetDateAt(this DateTime? dateTime, string format = "yyyy.MM.dd HH:mm:ss") => dateTime?.ToLocalTime().ToString(format) ?? null; // 변경 시간 남은 기간 일 수 계산 public static short GetChangeCycleDay(this DateTime? changedAt, ushort? cycleDay = 0) { if (cycleDay > 0 && cycleDay.HasValue) { if (changedAt.HasValue) { // 변경 가능 기간 계산 (현재 날짜 - 설정된 변경 기간) return (short)((cycleDay + 1) - (DateTime.UtcNow - changedAt.Value).TotalDays); // 남은 일수 계산 } } return 0; } // 현재 시간으로 부터 지정된 일수 이상 지난 날짜인지 확인 public static bool IsDateOverDue(this DateTime createdAt, ushort days) { return (DateTime.UtcNow - createdAt).TotalDays > days; } } }