Created
March 25, 2021 06:05
-
-
Save siteslave/2ef0d5c87430d8fe8c55aba8ab301e7f to your computer and use it in GitHub Desktop.
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
/* | |
main.dart | |
localizationsDelegates: [ | |
GlobalMaterialLocalizations.delegate, | |
GlobalWidgetsLocalizations.delegate, | |
], | |
supportedLocales: [ | |
const Locale('th', 'TH'), | |
], | |
*/ | |
import 'package:intl/intl.dart'; | |
class Helper { | |
Helper(); | |
String toThaiDate(DateTime date) { | |
// create format | |
var strDate = new DateFormat.MMMd('th_TH').format(date); | |
var _strDate = '$strDate ${date.year + 543}'; | |
// return thai date | |
return _strDate; | |
} | |
String toLongThaiDate(DateTime date) { | |
// create format | |
var strDate = new DateFormat.MMMMd('th_TH').format(date); | |
var _strDate = '$strDate ${date.year + 543}'; | |
// return thai date | |
return _strDate; | |
} | |
String toLongThaiDateAndTime(DateTime date) { | |
// create format | |
var strDate = new DateFormat.MMMMd('th_TH').format(date); | |
var strTime = new DateFormat.Hm().format(date); | |
var _strDate = '$strDate ${date.year + 543} $strTime'; | |
// return thai date | |
return _strDate; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment