feat: adopt material 3 theme and billing adjustments
This commit is contained in:
39
lib/utils/business_day_util.dart
Normal file
39
lib/utils/business_day_util.dart
Normal file
@@ -0,0 +1,39 @@
|
||||
/// 영업일 계산 유틸리티
|
||||
/// - 주말(토/일)과 일부 고정 공휴일을 제외하고 다음 영업일을 계산합니다.
|
||||
/// - 음력 기반 공휴일(설/추석 등)은 포함하지 않습니다. 필요 시 외부 소스 연동을 고려하세요.
|
||||
class BusinessDayUtil {
|
||||
static bool isWeekend(DateTime date) =>
|
||||
date.weekday == DateTime.saturday || date.weekday == DateTime.sunday;
|
||||
|
||||
/// 고정일 한국 공휴일(대체공휴일 미포함)
|
||||
static const List<String> _fixedHolidays = [
|
||||
'01-01', // 신정
|
||||
'03-01', // 삼일절
|
||||
'05-05', // 어린이날
|
||||
'06-06', // 현충일
|
||||
'08-15', // 광복절
|
||||
'10-03', // 개천절
|
||||
'10-09', // 한글날
|
||||
'12-25', // 성탄절
|
||||
];
|
||||
|
||||
static bool isFixedKoreanHoliday(DateTime date) {
|
||||
final key = '${_two(date.month)}-${_two(date.day)}';
|
||||
return _fixedHolidays.contains(key);
|
||||
}
|
||||
|
||||
static String _two(int n) => n.toString().padLeft(2, '0');
|
||||
|
||||
/// 입력 날짜가 주말/고정 공휴일이면 다음 영업일로 전진합니다.
|
||||
static DateTime nextBusinessDay(DateTime date) {
|
||||
var d = DateTime(date.year, date.month, date.day);
|
||||
while (isWeekend(d) || isFixedKoreanHoliday(d)) {
|
||||
d = d.add(const Duration(days: 1));
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
||||
/// 대상 월의 말일을 반환합니다.
|
||||
static int daysInMonth(int year, int month) =>
|
||||
DateTime(year, month + 1, 0).day;
|
||||
}
|
||||
Reference in New Issue
Block a user