Last active
April 9, 2020 19:28
-
-
Save kranfix/0b16ce2c2e9c94199dbd77b1abe54945 to your computer and use it in GitHub Desktop.
Dart extension example for parsing dates.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// 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