Skip to content

Instantly share code, notes, and snippets.

@mandymozart
Created November 13, 2015 14:29
Show Gist options
  • Save mandymozart/53889d7b2d1df2d17f61 to your computer and use it in GitHub Desktop.
Save mandymozart/53889d7b2d1df2d17f61 to your computer and use it in GitHub Desktop.
This class can be used to store additional information about dates, like timespans, etc. at the moment it is not implemented in the date_picker
/** Can store data for further Calendar interactions like timespans, extended information for individual dates.
* Not used for now
**/
class CalendarDates extends JsProxy {
@reflectable
List years = [];
static const maxYear = 2018;
static const minYear = 1970;
// Constructor fill object with dates from minimun to maximum years
CalendarDates() {
log.info('constructor');
//
var _date = new DateTime(minYear, 1, 1);
var _thoseYears = [];
var _thoseWeeks = [];
for (int y = minYear; y < maxYear; y++) {
var _thatYear = [];
for (int m = 1; m <= 12; m++) {
var _thatMonth = [];
for (int d = 1; d <= 31; d++) {
_date = new DateTime(y, m, d);
if (m != _date.month) break;
Map _thatDay = {
'date': _date,
'name': _date.toIso8601String(),
'year': _date.year,
'month': _date.month,
'day': _date.day,
'weekday': _date.weekday,
'UTC': _date.toUtc()
};
//log.info('$_thatDay');
_thatMonth.add(_thatDay);
}
_thatYear.add(_thatMonth);
}
_thoseYears.add(_thatYear);
}
this.years = _thoseYears;
//log.info(this.years);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment