You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.1 KiB
Dart
44 lines
1.1 KiB
Dart
import 'package:intl/intl.dart';
|
|
|
|
extension EmailValidator on String {
|
|
bool isValidEmail() {
|
|
return RegExp(r'^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$').hasMatch(this);
|
|
}
|
|
|
|
String toFormattedDate() {
|
|
String date = this.split("T")[0];
|
|
String time = this.split("T")[1];
|
|
var dates = date.split("-");
|
|
return "${dates[2]} ${getMonth(int.parse(dates[1]))} ${dates[0]} ${DateFormat('hh:mm a').format(DateFormat('hh:mm:ss').parse(time))}";
|
|
}
|
|
|
|
getMonth(int month) {
|
|
switch (month) {
|
|
case 1:
|
|
return "January";
|
|
case 2:
|
|
return "February";
|
|
case 3:
|
|
return "March";
|
|
case 4:
|
|
return "April";
|
|
case 5:
|
|
return "May";
|
|
case 6:
|
|
return "June";
|
|
case 7:
|
|
return "July";
|
|
case 8:
|
|
return "August";
|
|
case 9:
|
|
return "September";
|
|
case 10:
|
|
return "October";
|
|
case 11:
|
|
return "November";
|
|
case 12:
|
|
return "December";
|
|
}
|
|
}
|
|
}
|