format method
Return a string representing date
formatted
according to assigned _pattern
and _language
.
Implementation
String format(NepaliDateTime date) {
if (_firstRun) {
_checkPattern = _pattern;
_firstRun = false;
}
for (var i = 0; i < _matchers.length; i++) {
final regex = _matchers[i];
final match = regex.firstMatch(_checkPattern);
if (_checkPattern.isEmpty) return _pattern;
if (match != null) {
final matchedString = match.group(0);
if (matchedString != null) {
_checkPattern = _checkPattern.substring(matchedString.length);
switch (i) {
case 0:
_trim(matchedString);
format(date);
break;
case 1:
_format(matchedString, date);
format(date);
break;
case 2:
_index += matchedString.length;
format(date);
break;
}
}
}
}
return '';
}