Time.fromNotation constructor
Time.fromNotation( - String notation
)
Implementation
factory Time.fromNotation(String notation) {
int days = 0;
int hours = 0;
int minutes = 0;
int seconds = 0;
List<String> current = [];
String val = notation;
if (val.indexOf('d') == -1) {
days = 0;
} else {
current = val.split('d');
days = int.parse(current[0]);
if (current.length == 2) {
val = current[1];
} else
val = "";
}
if (val.indexOf('h') == -1) {
hours = 0;
} else {
current = val.split('h');
hours = int.parse(current[0]);
if (current.length == 2)
val = current[1];
else
val = "";
}
if (val.indexOf('m') == -1) {
minutes = 0;
} else {
current = val.split('m');
minutes = int.parse(current[0]);
if (current.length == 2)
val = current[1];
else
val = "";
}
if (val.indexOf('s') == -1) {
seconds = 0;
} else {
current = val.split('s');
seconds = int.parse(current[0]);
if (current.length == 2)
val = current[1];
else
val = "";
}
if (val != "") {
seconds += int.parse(val);
}
return Time(days: days, hours: hours, minutes: minutes, seconds: seconds);
}