當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Dart DateTime.operator_equals用法及代碼示例

dart:core 庫中DateTime.operator_equals 方法的用法介紹如下。

用法:

bool operator ==(
   Object other   
)
      override

如果 other 在同一時刻和同一時區(UTC 或本地)中是 DateTime,則返回 true。

final dDayUtc = DateTime.utc(1944, 6, 6);
final dDayLocal = dDayUtc.toLocal();

// These two dates are at the same moment, but are in different zones.
assert(dDayUtc != dDayLocal);
print(dDayUtc != dDayLocal); // true

請參閱isAtSameMomentAs,了解獨立於其區域比較時間點的比較。

相關用法


注:本文由純淨天空篩選整理自dart.dev大神的英文原創作品 operator == method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。