Created
April 1, 2021 11:55
-
-
Save samuchakraborty/112de56ace5bd4b2d1f1f1783ef90786 to your computer and use it in GitHub Desktop.
This file contains 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
import 'dart:convert'; | |
void main() { | |
String dateFormatter(DateTime date) { | |
dynamic dayData = | |
'{ "1" : "Mon", "2" : "Tue", "3" : "Wed", "4" : "Thur", "5" : "Fri", "6" : "Sat", "7" : "Sun" }'; | |
dynamic monthData = | |
'{ "1" : "Jan", "2" : "Feb", "3" : "Mar", "4" : "Apr", "5" : "May", "6" : "June", "7" : "Jul", "8" : "Aug", "9" : "Sep", "10" : "Oct", "11" : "Nov", "12" : "Dec" }'; | |
return json.decode(dayData)['${date.weekday}'] + | |
", " + | |
date.day.toString() + | |
" " + | |
json.decode(monthData)['${date.month}'] + | |
" " + | |
date.year.toString(); | |
} | |
DateTime now = DateTime.now(); | |
print(now.day); | |
print(now.year); | |
print(now.month); | |
if(now.day % 2 == 0){ | |
print("it is even day"); | |
} | |
else{ | |
var date = new DateTime(now.year - 3, now.month, now.day); | |
//var date = new DateTime(); | |
print(dateFormatter(date)); | |
print("it is odd day"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment