PersianDate.pDate constructor

PersianDate.pDate({
  1. String? defualtFormat,
  2. String? gregorian,
})

Implementation

PersianDate.pDate({String? defualtFormat, String? gregorian}) {
  var now;

  if (defualtFormat != null) this._defualtVal = defualtFormat;

  if (gregorian != null) {
    now = DateTime.parse(gregorian);
    List list = gregorianToJalali(now.year, now.month, now.day);
    setWeekday = now.weekday;
    this.setYear = list[0];
    this.setMonth = list[1];
    this.setDay = list[2];
    this.setHour = now.hour;
    this.setMinute = now.minute;
    this.setSecond = now.second;
    this.setMicrosecond = now.microsecond;
    this.setMillisecond = now.millisecond;
    _getDate = _toFormat(_defualtVal);
  } else {
    _getDate = _now();
  }
}