31 lines
883 B
Dart
31 lines
883 B
Dart
import 'package:json_annotation/json_annotation.dart';
|
|
|
|
part 'mc_holiday.g.dart';
|
|
|
|
@JsonSerializable(explicitToJson: true)
|
|
class McHoliday {
|
|
final String shortName;
|
|
final String longName;
|
|
|
|
@JsonKey(fromJson: _dateFromJson, toJson: _dateToJson)
|
|
final DateTime startDate;
|
|
|
|
@JsonKey(fromJson: _dateFromJson, toJson: _dateToJson)
|
|
final DateTime endDate;
|
|
|
|
McHoliday({
|
|
required this.shortName,
|
|
required this.longName,
|
|
required this.startDate,
|
|
required this.endDate,
|
|
});
|
|
|
|
factory McHoliday.fromJson(Map<String, dynamic> json) =>
|
|
_$McHolidayFromJson(json);
|
|
Map<String, dynamic> toJson() => _$McHolidayToJson(this);
|
|
|
|
static DateTime _dateFromJson(String raw) => DateTime.parse(raw);
|
|
static String _dateToJson(DateTime d) =>
|
|
'${d.year.toString().padLeft(4, '0')}-${d.month.toString().padLeft(2, '0')}-${d.day.toString().padLeft(2, '0')}';
|
|
}
|