Skip to content

Commit

Permalink
Merge branch 'hotfix/1.1.2' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
mouredev committed Aug 9, 2021
2 parents 0a2614b + e4c1095 commit bf78d96
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
8 changes: 4 additions & 4 deletions Twitimer.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1073,7 +1073,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = Twitimer/Twitimer.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_ASSET_PATHS = "\"Twitimer/Preview Content\"";
DEVELOPMENT_TEAM = SJGR47U9J5;
ENABLE_PREVIEWS = YES;
Expand All @@ -1084,7 +1084,7 @@
"@executable_path/Frameworks",
);
MACH_O_TYPE = mh_execute;
MARKETING_VERSION = 1.1.1;
MARKETING_VERSION = 1.1.2;
PRODUCT_BUNDLE_IDENTIFIER = com.mouredev.Twitimer;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand All @@ -1099,7 +1099,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = Twitimer/Twitimer.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_ASSET_PATHS = "\"Twitimer/Preview Content\"";
DEVELOPMENT_TEAM = SJGR47U9J5;
ENABLE_PREVIEWS = YES;
Expand All @@ -1110,7 +1110,7 @@
"@executable_path/Frameworks",
);
MACH_O_TYPE = mh_execute;
MARKETING_VERSION = 1.1.1;
MARKETING_VERSION = 1.1.2;
PRODUCT_BUNDLE_IDENTIFIER = com.mouredev.Twitimer;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand Down
2 changes: 1 addition & 1 deletion Twitimer/Model/Domain/User.swift
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ struct UserSchedule: Codable, Equatable {
date = updatedDate
}

date = date.next(nextWeekday, considerToday: true)
date = date.next(nextWeekday, considerToday: true, save: true)
}

return [DatabaseField.enable.rawValue:enable ? 1 : 0,
Expand Down
8 changes: 5 additions & 3 deletions Twitimer/Util/Extension/DateExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ extension Date {
return formatter.string(from: self)
}

func next(_ weekday: Weekday, considerToday: Bool = false, referenceDate: Date? = nil, duration: Int? = nil) -> Date {
func next(_ weekday: Weekday, considerToday: Bool = false, referenceDate: Date? = nil, duration: Int? = nil, save: Bool = true) -> Date {

let dayName = weekday.rawValue
let weekdaysName = getWeekDaysInEnglish().map { $0.lowercased() }
Expand All @@ -28,10 +28,12 @@ extension Date {
if considerToday && dayOfWeek == searchWeekdayIndex {
if let referenceDate = referenceDate, let duration = duration, referenceDate.addingTimeInterval(60 * 60 * Double(duration)) > self {
return referenceDate
} else if self > Date() {
} else if self.addingTimeInterval(60 * 60 * Double(duration ?? 0)) <= Date() {
return self
} else if save && self > Date() {
return self
}
}
}

var nextDateComponent = calendar.dateComponents([.hour, .minute, .second], from: self)
nextDateComponent.weekday = searchWeekdayIndex
Expand Down

0 comments on commit bf78d96

Please sign in to comment.