getServerDateTime method
Implementation
Future<String> getServerDateTime() async {
if (!kIsWeb) {
try {
http.Response res = await http.get(Uri.parse('https://mws.amazonservices.com/'));
RegExp exp = RegExp(r'timestamp="(.*)"', multiLine: true);
final match = exp.firstMatch(res.body);
if (match != null) {
return match.group(1).toString()
.replaceAll(RegExp(r'\.\d*Z$'), 'Z')
.replaceAll(RegExp(r'[:-]|\.\d{3}'), '');
}
// ignore: empty_catches
} catch (e) {}
}
return getDateTime();
}