Spec-Zone.ru › Dart 2

dart:core

Метод isAtSameMomentAs

bool isAtSameMomentAs(
  1. DateTime other
)

Возвращает true, если this происходит в тот же момент, что и other.

Сравнение не зависит от того, в часовом поясе UTC или в местном часовом поясе.

final now = DateTime.now();
final later = now.add(const Duration(seconds: 5));
print(!later.isAtSameMomentAs(now)); // true
print(now.isAtSameMomentAs(now)); // true

// This relation stays the same, even when changing timezones.
print(!later.isAtSameMomentAs(now.toUtc())); // true
print(!later.toUtc().isAtSameMomentAs(now)); // true

print(now.toUtc().isAtSameMomentAs(now)); // true
print(now.isAtSameMomentAs(now.toUtc())); // true

Реализация

external bool isAtSameMomentAs(DateTime other);

© 2012 the Dart project authors
Licensed under the BSD 3-Clause "New" or "Revised" License.
https://api.dart.dev/stable/2.18.5/dart-core/DateTime/isAtSameMomentAs.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API