Created
July 29, 2022 10:26
-
-
Save wilfrem/f150f4d12b85339d8800c87b09aeeb0b to your computer and use it in GitHub Desktop.
expire test
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
void main() async { | |
final now = DateTime.parse("2022-07-09 12:02:00"); | |
final expirationTime1 = DateTime.parse("2022-07-09 12:03:00"); | |
final expirationTime2 = DateTime.parse("2022-07-09 12:01:00"); | |
final n = now.add(const Duration(minutes: -2)); // 2min前 | |
final n2 = now.add(const Duration(minutes: 2)); // 2min前(修正版) | |
if (n.isBefore(expirationTime1)) { | |
print("not expired1"); | |
} else { | |
print("expired1"); | |
} | |
if (n.isBefore(expirationTime2)) { | |
print("not expired2"); | |
} else { | |
print("expired2"); | |
} | |
if (n2.isBefore(expirationTime1)) { | |
print("not expired3"); | |
} else { | |
print("expired3"); | |
} | |
if (n2.isBefore(expirationTime2)) { | |
print("not expired4"); | |
} else { | |
print("expired4"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment