Skip to content

Instantly share code, notes, and snippets.

@kranfix
Last active April 9, 2020 19:28
Show Gist options
  • Save kranfix/0b16ce2c2e9c94199dbd77b1abe54945 to your computer and use it in GitHub Desktop.
Save kranfix/0b16ce2c2e9c94199dbd77b1abe54945 to your computer and use it in GitHub Desktop.
Dart extension example for parsing dates.
/// Dart extension example for parsing dates.
///
/// gist: https://gist.github.com/kranfix/0b16ce2c2e9c94199dbd77b1abe54945
/// dartpad: https://dartpad.dev/0b16ce2c2e9c94199dbd77b1abe54945
extension DateTimeFormatterX on DateTime {
String get spanishDateString => '${this.day}/${this.month}/${this.year}';
}
void main() {
const backendDate = '2020-04-09T14:22:32.789';
final date = DateTime.parse(backendDate);
print('$backendDate => ${date.spanishDateString}');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment