🙂 İNSANLARIN EN HAYIRLISI INSANLARA FAYDALI OLANDIR 🙂

Ramazan HABER / FLUTTER / Tarih ile ilgili işlemler karşılaştırma vs kullanımı

1-) FLUTTER - Tarih ile ilgili işlemler karşılaştırma vs kullanımı

 

1-) compareto ile

 

DateTime dt1 = DateTime.parse("2021-12-23 11:47:00");
DateTime dt2 = DateTime.parse("2018-02-27 10:09:00");

if(dt1.compareTo(dt2) == 0){
  print(
"Both date time are at same moment.");
}

if(dt1.compareTo(dt2) < 0){
  print(
"DT1 is before DT2");
}

if(dt1.compareTo(dt2) > 0){
  print(
"DT1 is after DT2");
}

 

2-) isBefore ile

 

DateTime dt1 = DateTime.parse("2021-12-23 11:47:00");
DateTime dt2 = DateTime.parse("2018-02-27 10:09:00");

if(dt1.isBefore(dt2)){
  print(
"DT1 is before DT2");
}

 

3-) isAfter ile

 

DateTime dt1 = DateTime.parse("2021-12-23 11:47:00");
DateTime dt2 = DateTime.parse("2018-02-27 10:09:00");

if(dt1.isAfter(dt2)){
  print(
"DT1 is after DT2");
}

 

4-) isAtSameMomentAs ile

 

DateTime dt1 = DateTime.parse("2021-12-23 11:47:00");
DateTime dt2 = DateTime.parse(
"2018-02-27 10:09:00");

if(dt1.isAtSameMomentAs(dt2)){
  print(
"Both DateTime are at same moment.");
}

 

************ 1 gün nasıl eklenir ************

 

DateTime.parse(odaBilgileri.cikisTar).add(Duration(days: 1,))

 

************ KAYNAKLAR ************

 

kaynak : https://www.fluttercampus.com/guide/166/how-to-compare-two-datetime-in-dart-flutter/#datetime-isbefore-datetime-other

kaynak  : https://stackoverflow.com/questions/54792056/add-subtract-months-years-to-date-in-dart

 

 

 

2-) TARİH KOLAY İŞLEMLER

 

DateTime now = new DateTime.now();
int yil = now.year;
int ay = now.month;
int gun = now.day;
if (yil > 2022) {
  
return;
}

 

 

 2022 Ekim 25 Salı
 399