does this change will make a breaking change like affecting another parts of the package business logic? #293
Closed
khaledmurtaja
started this conversation in
General
Replies: 2 comments 1 reply
-
Thanks for your interest in the package ! No, this change shouldn't have any impact on other parts of the package business logic. To check if two alarms are in the same minute, you can update the code in the /// Extensions on [DateTime].
extension DateTimeExtension on DateTime {
/// Whether two [DateTime] are the same second.
bool isSameSecond(DateTime other) =>
year == other.year &&
month == other.month &&
day == other.day &&
hour == other.hour &&
minute == other.minute &&
second == other.second;
/// Whether two [DateTime] are the same minute.
bool isSameMinute(DateTime other) =>
year == other.year &&
month == other.month &&
day == other.day &&
hour == other.hour &&
minute == other.minute;
} and use it like this: static Future<bool> set({required AlarmSettings alarmSettings}) async {
alarmSettingsValidation(alarmSettings);
for (final alarm in getAlarms()) {
if (alarm.id == alarmSettings.id ||
alarm.dateTime.isSameMinute(alarmSettings.dateTime)) {
await Alarm.stop(alarm.id);
}
}
await AlarmStorage.saveAlarm(alarmSettings);
if (iOS) return IOSAlarm.setAlarm(alarmSettings);
if (android) return AndroidAlarm.set(alarmSettings);
updateStream.add(alarmSettings.id);
return false;
} Let me know if you notice something wrong or if you have any questions ! |
Beta Was this translation helpful? Give feedback.
0 replies
-
@khaledmurtaja I noticed in your profile that you’re from Gaza. I just want to take a moment to express that I hope you and your loved ones are staying safe during these incredibly difficult times. 🇵🇸 |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I changed the isSameSecond comparison to compare alarms by minute since my app is a normal alarm app which does not need exact alarm by second!
Beta Was this translation helpful? Give feedback.
All reactions