Viet Date Time

Hỗ trợ trong việc chuyển đổi và tính toán ngày tháng, thời gian và can chi theo lịch Việt Nam.

Sử Dụng

Khai báo theo ngày tháng cu thê:

// Ngày 1 tháng 10 năm 2023 và tháng 10 không phải tháng nhuần
final vietDateTime = VietDateTime(2023, 10, 1);

// Ngày 1 tháng 10 năm 2023 và tháng 10 và là tháng nhuần
final vietDateTime = VietDateTime.leapMonth(2023, 10, 1);

Chuyển đổi từ DateTime:

final vietDateTime = VietDateTime.now();
// Or
final vietDateTime = VietDateTime.fromDateTime(DateTime.now());
// Or
final vietDateTime = DateTime.now().toVietDateTime;

Chuyển từ VietDateTime sang DateTime:

final dateTime = vietDateTime.toDateTime();

Kiểm tra tháng hiện tại có phải tháng nhuần hay không

final isLeapMonth = vietDateTime.isLeapMonth;

Bạn có thể sử dụng các phép tính như DateTime và có thể sử dụng thay thế cho DateTime

vietDateTime.add(Duration(days: 3));
vietDateTime.compareTo(VietDateTime.fromSolar(DateTime.now()));

Thông tin các ngày lễ trong năm:

// Các ngày lễ theo âm lịch
// Kết quả sẽ là danh sách với thời gian tính theo `VietDateTime`
VietDateTime.lunarEvents;

// Các ngày lễ theo dương lịch
// Kết quả sẽ là danh sách với thời gian tính theo `DateTime`
VietDateTime.solarEvents; 

Libraries

viet_date_time