├── .codecov.yml ├── .gitignore ├── .swift-version ├── .travis.yml ├── Example ├── Podfile ├── SwiftCronExample.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcshareddata │ │ └── xcschemes │ │ ├── SwiftCronExample.xcscheme │ │ └── SwiftCronTests.xcscheme ├── SwiftCronExample.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist ├── SwiftCronExample │ ├── AppDelegate.swift │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ ├── Info.plist │ └── ViewController.swift └── SwiftCronExampleTests │ ├── CronExpressionTests.swift │ ├── Data Builders │ └── DateBuilder.swift │ ├── DayTests.swift │ ├── DescriptionTests.swift │ ├── Field Specific Tests │ └── MonthFieldTests.swift │ ├── HourTests.swift │ ├── Info.plist │ ├── MinuteTests.swift │ ├── MonthTests.swift │ ├── SwiftCronExampleTests-Bridging-Header.h │ ├── SwiftCronExampleTests.swift │ ├── SwiftCronTests.swift │ ├── Test Data │ └── TestData.swift │ ├── TestData.swift │ ├── Tests.swift │ ├── TimeZoneTests.swift │ ├── WeekdayTests.swift │ └── YearTests.swift ├── LICENSE ├── Package.swift ├── README.md ├── Sources ├── CronDescriptionBuilder.swift ├── CronExpression.swift ├── CronFieldTranslatable.swift ├── CronRepresentation.swift ├── DayOfMonthField.swift ├── DayOfWeekField.swift ├── Field.swift ├── FieldInterface.swift ├── HoursField.swift ├── Int+Extensions.swift ├── MinutesField.swift ├── MonthField.swift ├── NSDate+Extensions.swift ├── NSDateFormatter+Extensions.swift ├── String+Extensions.swift ├── StringValidator.swift └── YearField.swift ├── SwiftCron.podspec ├── SwiftCron.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── xcshareddata │ └── xcschemes │ └── SwiftCron.xcscheme └── SwiftCron ├── Info.plist └── SwiftCron.h /.codecov.yml: -------------------------------------------------------------------------------- 1 | ignore: 2 | - "Example/*" 3 | comment: 4 | layout: "header, diff" 5 | behavior: default 6 | require_changes: no 7 | coverage: 8 | status: 9 | project: 10 | default: 11 | target: auto 12 | threshold: null 13 | base: auto 14 | paths: "SwiftCron/*" 15 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.swp 3 | *~.nib 4 | */Pods/** 5 | Pods/** 6 | Example/Pods/** 7 | Example/Podfile.lock 8 | Example/.idea 9 | build/ 10 | .build/ 11 | 12 | *.pbxuser 13 | *.perspective 14 | *.perspectivev3 15 | 16 | xcuserdata 17 | -------------------------------------------------------------------------------- /.swift-version: -------------------------------------------------------------------------------- 1 | 5.0 2 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # references: 2 | # * http://www.objc.io/issue-6/travis-ci.html 3 | # * https://github.com/supermarin/xcpretty#usage 4 | 5 | language: objective-c 6 | osx_image: xcode8.1 7 | # cache: cocoapods 8 | # podfile: Example/Podfile 9 | # before_install: 10 | # - gem install cocoapods # Since Travis is not always on latest version 11 | # - pod install --project-directory=Example 12 | script: 13 | - cd Example && pod install 14 | - set -o pipefail && xcodebuild test -workspace SwiftCronExample.xcworkspace -scheme SwiftCronExample -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6,OS=9.3' ONLY_ACTIVE_ARCH=YES | xcpretty 15 | - cd .. && pod lib lint 16 | 17 | after_success: 18 | - bash <(curl -s https://codecov.io/bash) 19 | -------------------------------------------------------------------------------- /Example/Podfile: -------------------------------------------------------------------------------- 1 | use_frameworks! 2 | 3 | target 'SwiftCronExample' do 4 | pod 'SwiftCron', :path => '../' 5 | end 6 | 7 | target 'SwiftCronExampleTests' do 8 | pod 'SwiftCron', :path => '../' 9 | pod 'SwiftLint' 10 | end 11 | 12 | pre_install do |installer| 13 | def installer.verify_no_static_framework_transitive_dependencies; end 14 | end 15 | -------------------------------------------------------------------------------- /Example/SwiftCronExample.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 8679D2751CE1F4730071D783 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8679D2741CE1F4730071D783 /* AppDelegate.swift */; }; 11 | 8679D2771CE1F4730071D783 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8679D2761CE1F4730071D783 /* ViewController.swift */; }; 12 | 8679D27A1CE1F4730071D783 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8679D2781CE1F4730071D783 /* Main.storyboard */; }; 13 | 8679D27C1CE1F4730071D783 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 8679D27B1CE1F4730071D783 /* Assets.xcassets */; }; 14 | 8679D27F1CE1F4730071D783 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8679D27D1CE1F4730071D783 /* LaunchScreen.storyboard */; }; 15 | 8679D2A91CE1F5140071D783 /* DayTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8679D2A71CE1F5140071D783 /* DayTests.swift */; }; 16 | 8679D2AA1CE1F5140071D783 /* HourTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8679D2A81CE1F5140071D783 /* HourTests.swift */; }; 17 | 8679D2B11CE1F51F0071D783 /* MinuteTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8679D2AB1CE1F51F0071D783 /* MinuteTests.swift */; }; 18 | 8679D2B21CE1F51F0071D783 /* MonthTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8679D2AC1CE1F51F0071D783 /* MonthTests.swift */; }; 19 | 8679D2B31CE1F51F0071D783 /* SwiftCronTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8679D2AD1CE1F51F0071D783 /* SwiftCronTests.swift */; }; 20 | 8679D2B51CE1F51F0071D783 /* WeekdayTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8679D2AF1CE1F51F0071D783 /* WeekdayTests.swift */; }; 21 | 8679D2B61CE1F51F0071D783 /* YearTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8679D2B01CE1F51F0071D783 /* YearTests.swift */; }; 22 | 8679D2B81CE1FA760071D783 /* DescriptionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8679D2B71CE1FA760071D783 /* DescriptionTests.swift */; }; 23 | 9529D3581DD37D91005ACCE0 /* CronExpressionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9529D3571DD37D91005ACCE0 /* CronExpressionTests.swift */; }; 24 | 959A1B451D944A2700E685B3 /* MonthFieldTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 959A1B441D944A2700E685B3 /* MonthFieldTests.swift */; }; 25 | 959A1B481D944CE400E685B3 /* DateBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 959A1B471D944CE400E685B3 /* DateBuilder.swift */; }; 26 | 959A1B4D1D94518B00E685B3 /* TestData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 959A1B4C1D94518B00E685B3 /* TestData.swift */; }; 27 | C8B4BFA221A067E800222752 /* TimeZoneTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8B4BFA121A067E800222752 /* TimeZoneTests.swift */; }; 28 | E048D8BD8613C0CAF3BB4824 /* Pods_SwiftCronExample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EB8E7C90A033C373325A9FC6 /* Pods_SwiftCronExample.framework */; }; 29 | FDCC4D322535804B48C02ECA /* Pods_SwiftCronExampleTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9A585942BE5510532D56F9F1 /* Pods_SwiftCronExampleTests.framework */; }; 30 | /* End PBXBuildFile section */ 31 | 32 | /* Begin PBXContainerItemProxy section */ 33 | 8679D2861CE1F4740071D783 /* PBXContainerItemProxy */ = { 34 | isa = PBXContainerItemProxy; 35 | containerPortal = 8679D2691CE1F4730071D783 /* Project object */; 36 | proxyType = 1; 37 | remoteGlobalIDString = 8679D2701CE1F4730071D783; 38 | remoteInfo = SwiftCronExample; 39 | }; 40 | /* End PBXContainerItemProxy section */ 41 | 42 | /* Begin PBXFileReference section */ 43 | 0F8ABF1B000AF874C484BB4D /* Pods-SwiftCronExample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwiftCronExample.debug.xcconfig"; path = "Pods/Target Support Files/Pods-SwiftCronExample/Pods-SwiftCronExample.debug.xcconfig"; sourceTree = ""; }; 44 | 4E2C5421749CD7878ECB54E4 /* Pods-SwiftCronExampleTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwiftCronExampleTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-SwiftCronExampleTests/Pods-SwiftCronExampleTests.debug.xcconfig"; sourceTree = ""; }; 45 | 8679D2711CE1F4730071D783 /* SwiftCronExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SwiftCronExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 46 | 8679D2741CE1F4730071D783 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 47 | 8679D2761CE1F4730071D783 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 48 | 8679D2791CE1F4730071D783 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 49 | 8679D27B1CE1F4730071D783 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 50 | 8679D27E1CE1F4730071D783 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 51 | 8679D2801CE1F4730071D783 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 52 | 8679D2851CE1F4740071D783 /* SwiftCronExampleTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SwiftCronExampleTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 53 | 8679D28B1CE1F4740071D783 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 54 | 8679D2A61CE1F5130071D783 /* SwiftCronExampleTests-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SwiftCronExampleTests-Bridging-Header.h"; sourceTree = ""; }; 55 | 8679D2A71CE1F5140071D783 /* DayTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DayTests.swift; sourceTree = ""; }; 56 | 8679D2A81CE1F5140071D783 /* HourTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HourTests.swift; sourceTree = ""; }; 57 | 8679D2AB1CE1F51F0071D783 /* MinuteTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MinuteTests.swift; sourceTree = ""; }; 58 | 8679D2AC1CE1F51F0071D783 /* MonthTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MonthTests.swift; sourceTree = ""; }; 59 | 8679D2AD1CE1F51F0071D783 /* SwiftCronTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftCronTests.swift; sourceTree = ""; }; 60 | 8679D2AF1CE1F51F0071D783 /* WeekdayTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WeekdayTests.swift; sourceTree = ""; }; 61 | 8679D2B01CE1F51F0071D783 /* YearTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YearTests.swift; sourceTree = ""; }; 62 | 8679D2B71CE1FA760071D783 /* DescriptionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DescriptionTests.swift; sourceTree = ""; }; 63 | 86D78E8B1CF58EEE000CAD8A /* SwiftCron.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SwiftCron.framework; path = "../../../Library/Developer/Xcode/DerivedData/SwiftCronExample-cjweqqzmcjxhcufttvfiyyabbzfi/Build/Products/Debug-iphonesimulator/SwiftCron/SwiftCron.framework"; sourceTree = ""; }; 64 | 9529D3571DD37D91005ACCE0 /* CronExpressionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CronExpressionTests.swift; sourceTree = ""; }; 65 | 959A1B441D944A2700E685B3 /* MonthFieldTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = MonthFieldTests.swift; path = "Field Specific Tests/MonthFieldTests.swift"; sourceTree = ""; }; 66 | 959A1B471D944CE400E685B3 /* DateBuilder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = DateBuilder.swift; path = "Data Builders/DateBuilder.swift"; sourceTree = ""; }; 67 | 959A1B4C1D94518B00E685B3 /* TestData.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestData.swift; sourceTree = ""; }; 68 | 95BBA9DA1D0C16C3004C765A /* SwiftCron.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SwiftCron.framework; path = "../../../Library/Developer/Xcode/DerivedData/SwiftCronExample-adstpubkvtswoaboiajnrzswdzah/Build/Products/Debug-iphonesimulator/SwiftCron/SwiftCron.framework"; sourceTree = ""; }; 69 | 9A585942BE5510532D56F9F1 /* Pods_SwiftCronExampleTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_SwiftCronExampleTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 70 | 9FC712B82D2D075E149E73AB /* Pods-SwiftCronExampleTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwiftCronExampleTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-SwiftCronExampleTests/Pods-SwiftCronExampleTests.release.xcconfig"; sourceTree = ""; }; 71 | A8CB7B09FFB21F86177ED344 /* Pods-SwiftCronExample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwiftCronExample.release.xcconfig"; path = "Pods/Target Support Files/Pods-SwiftCronExample/Pods-SwiftCronExample.release.xcconfig"; sourceTree = ""; }; 72 | C8B4BFA121A067E800222752 /* TimeZoneTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimeZoneTests.swift; sourceTree = ""; }; 73 | EB8E7C90A033C373325A9FC6 /* Pods_SwiftCronExample.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_SwiftCronExample.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 74 | /* End PBXFileReference section */ 75 | 76 | /* Begin PBXFrameworksBuildPhase section */ 77 | 8679D26E1CE1F4730071D783 /* Frameworks */ = { 78 | isa = PBXFrameworksBuildPhase; 79 | buildActionMask = 2147483647; 80 | files = ( 81 | E048D8BD8613C0CAF3BB4824 /* Pods_SwiftCronExample.framework in Frameworks */, 82 | ); 83 | runOnlyForDeploymentPostprocessing = 0; 84 | }; 85 | 8679D2821CE1F4740071D783 /* Frameworks */ = { 86 | isa = PBXFrameworksBuildPhase; 87 | buildActionMask = 2147483647; 88 | files = ( 89 | FDCC4D322535804B48C02ECA /* Pods_SwiftCronExampleTests.framework in Frameworks */, 90 | ); 91 | runOnlyForDeploymentPostprocessing = 0; 92 | }; 93 | /* End PBXFrameworksBuildPhase section */ 94 | 95 | /* Begin PBXGroup section */ 96 | 4C8B47A9EA0B22235461D031 /* Frameworks */ = { 97 | isa = PBXGroup; 98 | children = ( 99 | 95BBA9DA1D0C16C3004C765A /* SwiftCron.framework */, 100 | 86D78E8B1CF58EEE000CAD8A /* SwiftCron.framework */, 101 | EB8E7C90A033C373325A9FC6 /* Pods_SwiftCronExample.framework */, 102 | 9A585942BE5510532D56F9F1 /* Pods_SwiftCronExampleTests.framework */, 103 | ); 104 | name = Frameworks; 105 | sourceTree = ""; 106 | }; 107 | 7714A611C69AD2EBBC5DE2B2 /* Pods */ = { 108 | isa = PBXGroup; 109 | children = ( 110 | 0F8ABF1B000AF874C484BB4D /* Pods-SwiftCronExample.debug.xcconfig */, 111 | A8CB7B09FFB21F86177ED344 /* Pods-SwiftCronExample.release.xcconfig */, 112 | 4E2C5421749CD7878ECB54E4 /* Pods-SwiftCronExampleTests.debug.xcconfig */, 113 | 9FC712B82D2D075E149E73AB /* Pods-SwiftCronExampleTests.release.xcconfig */, 114 | ); 115 | name = Pods; 116 | sourceTree = ""; 117 | }; 118 | 8679D2681CE1F4730071D783 = { 119 | isa = PBXGroup; 120 | children = ( 121 | 8679D2731CE1F4730071D783 /* SwiftCronExample */, 122 | 8679D2881CE1F4740071D783 /* SwiftCronExampleTests */, 123 | 8679D2721CE1F4730071D783 /* Products */, 124 | 7714A611C69AD2EBBC5DE2B2 /* Pods */, 125 | 4C8B47A9EA0B22235461D031 /* Frameworks */, 126 | ); 127 | sourceTree = ""; 128 | }; 129 | 8679D2721CE1F4730071D783 /* Products */ = { 130 | isa = PBXGroup; 131 | children = ( 132 | 8679D2711CE1F4730071D783 /* SwiftCronExample.app */, 133 | 8679D2851CE1F4740071D783 /* SwiftCronExampleTests.xctest */, 134 | ); 135 | name = Products; 136 | sourceTree = ""; 137 | }; 138 | 8679D2731CE1F4730071D783 /* SwiftCronExample */ = { 139 | isa = PBXGroup; 140 | children = ( 141 | 8679D2741CE1F4730071D783 /* AppDelegate.swift */, 142 | 8679D2761CE1F4730071D783 /* ViewController.swift */, 143 | 8679D2781CE1F4730071D783 /* Main.storyboard */, 144 | 8679D27B1CE1F4730071D783 /* Assets.xcassets */, 145 | 8679D27D1CE1F4730071D783 /* LaunchScreen.storyboard */, 146 | 8679D2801CE1F4730071D783 /* Info.plist */, 147 | ); 148 | path = SwiftCronExample; 149 | sourceTree = ""; 150 | }; 151 | 8679D2881CE1F4740071D783 /* SwiftCronExampleTests */ = { 152 | isa = PBXGroup; 153 | children = ( 154 | 959A1B491D94500900E685B3 /* Test Data */, 155 | 959A1B461D944C7E00E685B3 /* Data Builders */, 156 | 959A1B431D9449EF00E685B3 /* Field Specific Tests */, 157 | 8679D2A71CE1F5140071D783 /* DayTests.swift */, 158 | 8679D2AB1CE1F51F0071D783 /* MinuteTests.swift */, 159 | 8679D2AC1CE1F51F0071D783 /* MonthTests.swift */, 160 | 8679D2AD1CE1F51F0071D783 /* SwiftCronTests.swift */, 161 | 8679D2AF1CE1F51F0071D783 /* WeekdayTests.swift */, 162 | 8679D2B01CE1F51F0071D783 /* YearTests.swift */, 163 | 8679D2A81CE1F5140071D783 /* HourTests.swift */, 164 | 8679D28B1CE1F4740071D783 /* Info.plist */, 165 | 8679D2A61CE1F5130071D783 /* SwiftCronExampleTests-Bridging-Header.h */, 166 | 8679D2B71CE1FA760071D783 /* DescriptionTests.swift */, 167 | 9529D3571DD37D91005ACCE0 /* CronExpressionTests.swift */, 168 | C8B4BFA121A067E800222752 /* TimeZoneTests.swift */, 169 | ); 170 | path = SwiftCronExampleTests; 171 | sourceTree = ""; 172 | }; 173 | 959A1B431D9449EF00E685B3 /* Field Specific Tests */ = { 174 | isa = PBXGroup; 175 | children = ( 176 | 959A1B441D944A2700E685B3 /* MonthFieldTests.swift */, 177 | ); 178 | name = "Field Specific Tests"; 179 | sourceTree = ""; 180 | }; 181 | 959A1B461D944C7E00E685B3 /* Data Builders */ = { 182 | isa = PBXGroup; 183 | children = ( 184 | 959A1B471D944CE400E685B3 /* DateBuilder.swift */, 185 | ); 186 | name = "Data Builders"; 187 | sourceTree = ""; 188 | }; 189 | 959A1B491D94500900E685B3 /* Test Data */ = { 190 | isa = PBXGroup; 191 | children = ( 192 | 959A1B4C1D94518B00E685B3 /* TestData.swift */, 193 | ); 194 | name = "Test Data"; 195 | sourceTree = ""; 196 | }; 197 | /* End PBXGroup section */ 198 | 199 | /* Begin PBXNativeTarget section */ 200 | 8679D2701CE1F4730071D783 /* SwiftCronExample */ = { 201 | isa = PBXNativeTarget; 202 | buildConfigurationList = 8679D28E1CE1F4740071D783 /* Build configuration list for PBXNativeTarget "SwiftCronExample" */; 203 | buildPhases = ( 204 | E87025957E0569C2E0F11DA7 /* [CP] Check Pods Manifest.lock */, 205 | 8679D26D1CE1F4730071D783 /* Sources */, 206 | 8679D26E1CE1F4730071D783 /* Frameworks */, 207 | 8679D26F1CE1F4730071D783 /* Resources */, 208 | 955360B1207221680040C5C5 /* Run SwiftLint */, 209 | 42C8277495ABC8132337E07F /* [CP] Embed Pods Frameworks */, 210 | ); 211 | buildRules = ( 212 | ); 213 | dependencies = ( 214 | ); 215 | name = SwiftCronExample; 216 | productName = SwiftCronExample; 217 | productReference = 8679D2711CE1F4730071D783 /* SwiftCronExample.app */; 218 | productType = "com.apple.product-type.application"; 219 | }; 220 | 8679D2841CE1F4740071D783 /* SwiftCronExampleTests */ = { 221 | isa = PBXNativeTarget; 222 | buildConfigurationList = 8679D2911CE1F4740071D783 /* Build configuration list for PBXNativeTarget "SwiftCronExampleTests" */; 223 | buildPhases = ( 224 | 5C3A63B070FA8E0262619C5B /* [CP] Check Pods Manifest.lock */, 225 | 8679D2811CE1F4740071D783 /* Sources */, 226 | 8679D2821CE1F4740071D783 /* Frameworks */, 227 | 8679D2831CE1F4740071D783 /* Resources */, 228 | FB1006182B176A61E545DAAD /* [CP] Embed Pods Frameworks */, 229 | ); 230 | buildRules = ( 231 | ); 232 | dependencies = ( 233 | 8679D2871CE1F4740071D783 /* PBXTargetDependency */, 234 | ); 235 | name = SwiftCronExampleTests; 236 | productName = SwiftCronExampleTests; 237 | productReference = 8679D2851CE1F4740071D783 /* SwiftCronExampleTests.xctest */; 238 | productType = "com.apple.product-type.bundle.unit-test"; 239 | }; 240 | /* End PBXNativeTarget section */ 241 | 242 | /* Begin PBXProject section */ 243 | 8679D2691CE1F4730071D783 /* Project object */ = { 244 | isa = PBXProject; 245 | attributes = { 246 | LastSwiftUpdateCheck = 0730; 247 | LastUpgradeCheck = 0930; 248 | ORGANIZATIONNAME = Rush42; 249 | TargetAttributes = { 250 | 8679D2701CE1F4730071D783 = { 251 | CreatedOnToolsVersion = 7.3; 252 | LastSwiftMigration = 0930; 253 | }; 254 | 8679D2841CE1F4740071D783 = { 255 | CreatedOnToolsVersion = 7.3; 256 | LastSwiftMigration = 0930; 257 | TestTargetID = 8679D2701CE1F4730071D783; 258 | }; 259 | }; 260 | }; 261 | buildConfigurationList = 8679D26C1CE1F4730071D783 /* Build configuration list for PBXProject "SwiftCronExample" */; 262 | compatibilityVersion = "Xcode 3.2"; 263 | developmentRegion = English; 264 | hasScannedForEncodings = 0; 265 | knownRegions = ( 266 | English, 267 | en, 268 | Base, 269 | ); 270 | mainGroup = 8679D2681CE1F4730071D783; 271 | productRefGroup = 8679D2721CE1F4730071D783 /* Products */; 272 | projectDirPath = ""; 273 | projectRoot = ""; 274 | targets = ( 275 | 8679D2701CE1F4730071D783 /* SwiftCronExample */, 276 | 8679D2841CE1F4740071D783 /* SwiftCronExampleTests */, 277 | ); 278 | }; 279 | /* End PBXProject section */ 280 | 281 | /* Begin PBXResourcesBuildPhase section */ 282 | 8679D26F1CE1F4730071D783 /* Resources */ = { 283 | isa = PBXResourcesBuildPhase; 284 | buildActionMask = 2147483647; 285 | files = ( 286 | 8679D27F1CE1F4730071D783 /* LaunchScreen.storyboard in Resources */, 287 | 8679D27C1CE1F4730071D783 /* Assets.xcassets in Resources */, 288 | 8679D27A1CE1F4730071D783 /* Main.storyboard in Resources */, 289 | ); 290 | runOnlyForDeploymentPostprocessing = 0; 291 | }; 292 | 8679D2831CE1F4740071D783 /* Resources */ = { 293 | isa = PBXResourcesBuildPhase; 294 | buildActionMask = 2147483647; 295 | files = ( 296 | ); 297 | runOnlyForDeploymentPostprocessing = 0; 298 | }; 299 | /* End PBXResourcesBuildPhase section */ 300 | 301 | /* Begin PBXShellScriptBuildPhase section */ 302 | 42C8277495ABC8132337E07F /* [CP] Embed Pods Frameworks */ = { 303 | isa = PBXShellScriptBuildPhase; 304 | buildActionMask = 2147483647; 305 | files = ( 306 | ); 307 | inputPaths = ( 308 | "${PODS_ROOT}/Target Support Files/Pods-SwiftCronExample/Pods-SwiftCronExample-frameworks.sh", 309 | "${BUILT_PRODUCTS_DIR}/SwiftCron/SwiftCron.framework", 310 | ); 311 | name = "[CP] Embed Pods Frameworks"; 312 | outputPaths = ( 313 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwiftCron.framework", 314 | ); 315 | runOnlyForDeploymentPostprocessing = 0; 316 | shellPath = /bin/sh; 317 | shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-SwiftCronExample/Pods-SwiftCronExample-frameworks.sh\"\n"; 318 | showEnvVarsInLog = 0; 319 | }; 320 | 5C3A63B070FA8E0262619C5B /* [CP] Check Pods Manifest.lock */ = { 321 | isa = PBXShellScriptBuildPhase; 322 | buildActionMask = 2147483647; 323 | files = ( 324 | ); 325 | inputPaths = ( 326 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock", 327 | "${PODS_ROOT}/Manifest.lock", 328 | ); 329 | name = "[CP] Check Pods Manifest.lock"; 330 | outputPaths = ( 331 | "$(DERIVED_FILE_DIR)/Pods-SwiftCronExampleTests-checkManifestLockResult.txt", 332 | ); 333 | runOnlyForDeploymentPostprocessing = 0; 334 | shellPath = /bin/sh; 335 | shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; 336 | showEnvVarsInLog = 0; 337 | }; 338 | 955360B1207221680040C5C5 /* Run SwiftLint */ = { 339 | isa = PBXShellScriptBuildPhase; 340 | buildActionMask = 2147483647; 341 | files = ( 342 | ); 343 | inputPaths = ( 344 | ); 345 | name = "Run SwiftLint"; 346 | outputPaths = ( 347 | ); 348 | runOnlyForDeploymentPostprocessing = 0; 349 | shellPath = /bin/sh; 350 | shellScript = "\"${PODS_ROOT}/SwiftLint/swiftlint\"\n"; 351 | }; 352 | E87025957E0569C2E0F11DA7 /* [CP] Check Pods Manifest.lock */ = { 353 | isa = PBXShellScriptBuildPhase; 354 | buildActionMask = 2147483647; 355 | files = ( 356 | ); 357 | inputPaths = ( 358 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock", 359 | "${PODS_ROOT}/Manifest.lock", 360 | ); 361 | name = "[CP] Check Pods Manifest.lock"; 362 | outputPaths = ( 363 | "$(DERIVED_FILE_DIR)/Pods-SwiftCronExample-checkManifestLockResult.txt", 364 | ); 365 | runOnlyForDeploymentPostprocessing = 0; 366 | shellPath = /bin/sh; 367 | shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; 368 | showEnvVarsInLog = 0; 369 | }; 370 | FB1006182B176A61E545DAAD /* [CP] Embed Pods Frameworks */ = { 371 | isa = PBXShellScriptBuildPhase; 372 | buildActionMask = 2147483647; 373 | files = ( 374 | ); 375 | inputPaths = ( 376 | "${PODS_ROOT}/Target Support Files/Pods-SwiftCronExampleTests/Pods-SwiftCronExampleTests-frameworks.sh", 377 | "${BUILT_PRODUCTS_DIR}/SwiftCron/SwiftCron.framework", 378 | ); 379 | name = "[CP] Embed Pods Frameworks"; 380 | outputPaths = ( 381 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwiftCron.framework", 382 | ); 383 | runOnlyForDeploymentPostprocessing = 0; 384 | shellPath = /bin/sh; 385 | shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-SwiftCronExampleTests/Pods-SwiftCronExampleTests-frameworks.sh\"\n"; 386 | showEnvVarsInLog = 0; 387 | }; 388 | /* End PBXShellScriptBuildPhase section */ 389 | 390 | /* Begin PBXSourcesBuildPhase section */ 391 | 8679D26D1CE1F4730071D783 /* Sources */ = { 392 | isa = PBXSourcesBuildPhase; 393 | buildActionMask = 2147483647; 394 | files = ( 395 | 8679D2771CE1F4730071D783 /* ViewController.swift in Sources */, 396 | 8679D2751CE1F4730071D783 /* AppDelegate.swift in Sources */, 397 | ); 398 | runOnlyForDeploymentPostprocessing = 0; 399 | }; 400 | 8679D2811CE1F4740071D783 /* Sources */ = { 401 | isa = PBXSourcesBuildPhase; 402 | buildActionMask = 2147483647; 403 | files = ( 404 | 8679D2B81CE1FA760071D783 /* DescriptionTests.swift in Sources */, 405 | 959A1B4D1D94518B00E685B3 /* TestData.swift in Sources */, 406 | 8679D2B21CE1F51F0071D783 /* MonthTests.swift in Sources */, 407 | 8679D2B51CE1F51F0071D783 /* WeekdayTests.swift in Sources */, 408 | C8B4BFA221A067E800222752 /* TimeZoneTests.swift in Sources */, 409 | 8679D2B11CE1F51F0071D783 /* MinuteTests.swift in Sources */, 410 | 9529D3581DD37D91005ACCE0 /* CronExpressionTests.swift in Sources */, 411 | 8679D2B31CE1F51F0071D783 /* SwiftCronTests.swift in Sources */, 412 | 8679D2A91CE1F5140071D783 /* DayTests.swift in Sources */, 413 | 8679D2B61CE1F51F0071D783 /* YearTests.swift in Sources */, 414 | 8679D2AA1CE1F5140071D783 /* HourTests.swift in Sources */, 415 | 959A1B451D944A2700E685B3 /* MonthFieldTests.swift in Sources */, 416 | 959A1B481D944CE400E685B3 /* DateBuilder.swift in Sources */, 417 | ); 418 | runOnlyForDeploymentPostprocessing = 0; 419 | }; 420 | /* End PBXSourcesBuildPhase section */ 421 | 422 | /* Begin PBXTargetDependency section */ 423 | 8679D2871CE1F4740071D783 /* PBXTargetDependency */ = { 424 | isa = PBXTargetDependency; 425 | target = 8679D2701CE1F4730071D783 /* SwiftCronExample */; 426 | targetProxy = 8679D2861CE1F4740071D783 /* PBXContainerItemProxy */; 427 | }; 428 | /* End PBXTargetDependency section */ 429 | 430 | /* Begin PBXVariantGroup section */ 431 | 8679D2781CE1F4730071D783 /* Main.storyboard */ = { 432 | isa = PBXVariantGroup; 433 | children = ( 434 | 8679D2791CE1F4730071D783 /* Base */, 435 | ); 436 | name = Main.storyboard; 437 | sourceTree = ""; 438 | }; 439 | 8679D27D1CE1F4730071D783 /* LaunchScreen.storyboard */ = { 440 | isa = PBXVariantGroup; 441 | children = ( 442 | 8679D27E1CE1F4730071D783 /* Base */, 443 | ); 444 | name = LaunchScreen.storyboard; 445 | sourceTree = ""; 446 | }; 447 | /* End PBXVariantGroup section */ 448 | 449 | /* Begin XCBuildConfiguration section */ 450 | 8679D28C1CE1F4740071D783 /* Debug */ = { 451 | isa = XCBuildConfiguration; 452 | buildSettings = { 453 | ALWAYS_SEARCH_USER_PATHS = NO; 454 | CLANG_ANALYZER_NONNULL = YES; 455 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 456 | CLANG_CXX_LIBRARY = "libc++"; 457 | CLANG_ENABLE_MODULES = YES; 458 | CLANG_ENABLE_OBJC_ARC = YES; 459 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 460 | CLANG_WARN_BOOL_CONVERSION = YES; 461 | CLANG_WARN_COMMA = YES; 462 | CLANG_WARN_CONSTANT_CONVERSION = YES; 463 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 464 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 465 | CLANG_WARN_EMPTY_BODY = YES; 466 | CLANG_WARN_ENUM_CONVERSION = YES; 467 | CLANG_WARN_INFINITE_RECURSION = YES; 468 | CLANG_WARN_INT_CONVERSION = YES; 469 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 470 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 471 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 472 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 473 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 474 | CLANG_WARN_STRICT_PROTOTYPES = YES; 475 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 476 | CLANG_WARN_UNREACHABLE_CODE = YES; 477 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 478 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 479 | COPY_PHASE_STRIP = NO; 480 | DEBUG_INFORMATION_FORMAT = dwarf; 481 | ENABLE_STRICT_OBJC_MSGSEND = YES; 482 | ENABLE_TESTABILITY = YES; 483 | GCC_C_LANGUAGE_STANDARD = gnu99; 484 | GCC_DYNAMIC_NO_PIC = NO; 485 | GCC_NO_COMMON_BLOCKS = YES; 486 | GCC_OPTIMIZATION_LEVEL = 0; 487 | GCC_PREPROCESSOR_DEFINITIONS = ( 488 | "DEBUG=1", 489 | "$(inherited)", 490 | ); 491 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 492 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 493 | GCC_WARN_UNDECLARED_SELECTOR = YES; 494 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 495 | GCC_WARN_UNUSED_FUNCTION = YES; 496 | GCC_WARN_UNUSED_VARIABLE = YES; 497 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 498 | MTL_ENABLE_DEBUG_INFO = YES; 499 | ONLY_ACTIVE_ARCH = YES; 500 | SDKROOT = iphoneos; 501 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 502 | SWIFT_VERSION = 5.0; 503 | }; 504 | name = Debug; 505 | }; 506 | 8679D28D1CE1F4740071D783 /* Release */ = { 507 | isa = XCBuildConfiguration; 508 | buildSettings = { 509 | ALWAYS_SEARCH_USER_PATHS = NO; 510 | CLANG_ANALYZER_NONNULL = YES; 511 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 512 | CLANG_CXX_LIBRARY = "libc++"; 513 | CLANG_ENABLE_MODULES = YES; 514 | CLANG_ENABLE_OBJC_ARC = YES; 515 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 516 | CLANG_WARN_BOOL_CONVERSION = YES; 517 | CLANG_WARN_COMMA = YES; 518 | CLANG_WARN_CONSTANT_CONVERSION = YES; 519 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 520 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 521 | CLANG_WARN_EMPTY_BODY = YES; 522 | CLANG_WARN_ENUM_CONVERSION = YES; 523 | CLANG_WARN_INFINITE_RECURSION = YES; 524 | CLANG_WARN_INT_CONVERSION = YES; 525 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 526 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 527 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 528 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 529 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 530 | CLANG_WARN_STRICT_PROTOTYPES = YES; 531 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 532 | CLANG_WARN_UNREACHABLE_CODE = YES; 533 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 534 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 535 | COPY_PHASE_STRIP = NO; 536 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 537 | ENABLE_NS_ASSERTIONS = NO; 538 | ENABLE_STRICT_OBJC_MSGSEND = YES; 539 | GCC_C_LANGUAGE_STANDARD = gnu99; 540 | GCC_NO_COMMON_BLOCKS = YES; 541 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 542 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 543 | GCC_WARN_UNDECLARED_SELECTOR = YES; 544 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 545 | GCC_WARN_UNUSED_FUNCTION = YES; 546 | GCC_WARN_UNUSED_VARIABLE = YES; 547 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 548 | MTL_ENABLE_DEBUG_INFO = NO; 549 | SDKROOT = iphoneos; 550 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 551 | SWIFT_VERSION = 5.0; 552 | VALIDATE_PRODUCT = YES; 553 | }; 554 | name = Release; 555 | }; 556 | 8679D28F1CE1F4740071D783 /* Debug */ = { 557 | isa = XCBuildConfiguration; 558 | baseConfigurationReference = 0F8ABF1B000AF874C484BB4D /* Pods-SwiftCronExample.debug.xcconfig */; 559 | buildSettings = { 560 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = "$(inherited)"; 561 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 562 | INFOPLIST_FILE = SwiftCronExample/Info.plist; 563 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 564 | PRODUCT_BUNDLE_IDENTIFIER = com.Rush42.SwiftCronExample; 565 | PRODUCT_NAME = "$(TARGET_NAME)"; 566 | SWIFT_SWIFT3_OBJC_INFERENCE = Off; 567 | SWIFT_VERSION = 5.0; 568 | }; 569 | name = Debug; 570 | }; 571 | 8679D2901CE1F4740071D783 /* Release */ = { 572 | isa = XCBuildConfiguration; 573 | baseConfigurationReference = A8CB7B09FFB21F86177ED344 /* Pods-SwiftCronExample.release.xcconfig */; 574 | buildSettings = { 575 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = "$(inherited)"; 576 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 577 | INFOPLIST_FILE = SwiftCronExample/Info.plist; 578 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 579 | PRODUCT_BUNDLE_IDENTIFIER = com.Rush42.SwiftCronExample; 580 | PRODUCT_NAME = "$(TARGET_NAME)"; 581 | SWIFT_SWIFT3_OBJC_INFERENCE = Off; 582 | SWIFT_VERSION = 5.0; 583 | }; 584 | name = Release; 585 | }; 586 | 8679D2921CE1F4740071D783 /* Debug */ = { 587 | isa = XCBuildConfiguration; 588 | baseConfigurationReference = 4E2C5421749CD7878ECB54E4 /* Pods-SwiftCronExampleTests.debug.xcconfig */; 589 | buildSettings = { 590 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = "$(inherited)"; 591 | BUNDLE_LOADER = "$(TEST_HOST)"; 592 | CLANG_ENABLE_MODULES = YES; 593 | INFOPLIST_FILE = SwiftCronExampleTests/Info.plist; 594 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 595 | PRODUCT_BUNDLE_IDENTIFIER = com.Rush42.SwiftCronExampleTests; 596 | PRODUCT_NAME = "$(TARGET_NAME)"; 597 | SWIFT_OBJC_BRIDGING_HEADER = "SwiftCronExampleTests/SwiftCronExampleTests-Bridging-Header.h"; 598 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 599 | SWIFT_SWIFT3_OBJC_INFERENCE = Off; 600 | SWIFT_VERSION = 5.0; 601 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SwiftCronExample.app/SwiftCronExample"; 602 | }; 603 | name = Debug; 604 | }; 605 | 8679D2931CE1F4740071D783 /* Release */ = { 606 | isa = XCBuildConfiguration; 607 | baseConfigurationReference = 9FC712B82D2D075E149E73AB /* Pods-SwiftCronExampleTests.release.xcconfig */; 608 | buildSettings = { 609 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = "$(inherited)"; 610 | BUNDLE_LOADER = "$(TEST_HOST)"; 611 | CLANG_ENABLE_MODULES = YES; 612 | INFOPLIST_FILE = SwiftCronExampleTests/Info.plist; 613 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 614 | PRODUCT_BUNDLE_IDENTIFIER = com.Rush42.SwiftCronExampleTests; 615 | PRODUCT_NAME = "$(TARGET_NAME)"; 616 | SWIFT_OBJC_BRIDGING_HEADER = "SwiftCronExampleTests/SwiftCronExampleTests-Bridging-Header.h"; 617 | SWIFT_SWIFT3_OBJC_INFERENCE = Off; 618 | SWIFT_VERSION = 5.0; 619 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SwiftCronExample.app/SwiftCronExample"; 620 | }; 621 | name = Release; 622 | }; 623 | /* End XCBuildConfiguration section */ 624 | 625 | /* Begin XCConfigurationList section */ 626 | 8679D26C1CE1F4730071D783 /* Build configuration list for PBXProject "SwiftCronExample" */ = { 627 | isa = XCConfigurationList; 628 | buildConfigurations = ( 629 | 8679D28C1CE1F4740071D783 /* Debug */, 630 | 8679D28D1CE1F4740071D783 /* Release */, 631 | ); 632 | defaultConfigurationIsVisible = 0; 633 | defaultConfigurationName = Release; 634 | }; 635 | 8679D28E1CE1F4740071D783 /* Build configuration list for PBXNativeTarget "SwiftCronExample" */ = { 636 | isa = XCConfigurationList; 637 | buildConfigurations = ( 638 | 8679D28F1CE1F4740071D783 /* Debug */, 639 | 8679D2901CE1F4740071D783 /* Release */, 640 | ); 641 | defaultConfigurationIsVisible = 0; 642 | defaultConfigurationName = Release; 643 | }; 644 | 8679D2911CE1F4740071D783 /* Build configuration list for PBXNativeTarget "SwiftCronExampleTests" */ = { 645 | isa = XCConfigurationList; 646 | buildConfigurations = ( 647 | 8679D2921CE1F4740071D783 /* Debug */, 648 | 8679D2931CE1F4740071D783 /* Release */, 649 | ); 650 | defaultConfigurationIsVisible = 0; 651 | defaultConfigurationName = Release; 652 | }; 653 | /* End XCConfigurationList section */ 654 | }; 655 | rootObject = 8679D2691CE1F4730071D783 /* Project object */; 656 | } 657 | -------------------------------------------------------------------------------- /Example/SwiftCronExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Example/SwiftCronExample.xcodeproj/xcshareddata/xcschemes/SwiftCronExample.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 31 | 32 | 34 | 40 | 41 | 42 | 43 | 44 | 50 | 51 | 52 | 53 | 54 | 55 | 65 | 67 | 73 | 74 | 75 | 76 | 77 | 78 | 84 | 86 | 92 | 93 | 94 | 95 | 97 | 98 | 101 | 102 | 103 | -------------------------------------------------------------------------------- /Example/SwiftCronExample.xcodeproj/xcshareddata/xcschemes/SwiftCronTests.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 31 | 32 | 34 | 40 | 41 | 42 | 43 | 44 | 50 | 51 | 52 | 53 | 54 | 55 | 65 | 66 | 72 | 73 | 74 | 75 | 76 | 77 | 83 | 84 | 90 | 91 | 92 | 93 | 95 | 96 | 99 | 100 | 101 | -------------------------------------------------------------------------------- /Example/SwiftCronExample.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Example/SwiftCronExample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Example/SwiftCronExample/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // SwiftCronExample 4 | // 5 | // Created by Keegan Rush on 2016/05/10. 6 | // Copyright © 2016 Rush42. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import SwiftCron 11 | 12 | @UIApplicationMain 13 | class AppDelegate: UIResponder, UIApplicationDelegate { 14 | 15 | var window: UIWindow? 16 | 17 | func application( 18 | _ application: UIApplication, didFinishLaunchingWithOptions 19 | launchOptions: [UIApplication.LaunchOptionsKey: Any]?) 20 | -> Bool { 21 | return true 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /Example/SwiftCronExample/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /Example/SwiftCronExample/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Example/SwiftCronExample/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Example/SwiftCronExample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /Example/SwiftCronExample/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // SwiftCronExample 4 | // 5 | // Created by Keegan Rush on 2016/05/10. 6 | // Copyright © 2016 Rush42. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import SwiftCron 11 | 12 | class ViewController: UIViewController { 13 | 14 | } 15 | -------------------------------------------------------------------------------- /Example/SwiftCronExampleTests/CronExpressionTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CronExpressionTests.swift 3 | // SwiftCronExample 4 | // 5 | // Created by Keegan Rush on 2016/11/09. 6 | // Copyright © 2016 Rush42. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import XCTest 11 | 12 | @testable import SwiftCron 13 | 14 | class CronExpressionTests: XCTestCase { 15 | 16 | func testCreatingCronExpressionWithInvalidValueReturnsNil() { 17 | let invalidDay = "!@# $%^" 18 | let cronExpression = CronExpression(minute: "4", hour: "3", 19 | day: invalidDay, month: "1", 20 | weekday: "2", year: "2016") 21 | 22 | XCTAssertNil(cronExpression) 23 | } 24 | 25 | func testCronStringIsCorrect() { 26 | let cronString = "1 2 3 4 5 6" 27 | let cronExpression = CronExpression(cronString: cronString)! 28 | 29 | XCTAssertEqual(cronExpression.stringRepresentation, cronString) 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Example/SwiftCronExampleTests/Data Builders/DateBuilder.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DateBuilder.swift 3 | // SwiftCronExample 4 | // 5 | // Created by Keegan Rush on 2016/09/22. 6 | // Copyright © 2016 Rush42. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | class DateBuilder { 12 | 13 | private var day: Int? 14 | private var month: Int? 15 | private var year: Int? 16 | 17 | func build() -> Date { 18 | let components = DateComponents(calendar: Calendar.current, year: year, month: month, day: day) 19 | return components.date! 20 | } 21 | 22 | func with(year: Int) -> DateBuilder { 23 | self.year = year 24 | return self 25 | } 26 | 27 | func with(month: Int) -> DateBuilder { 28 | self.month = month 29 | return self 30 | } 31 | 32 | func with(day: Int) -> DateBuilder { 33 | self.day = day 34 | return self 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /Example/SwiftCronExampleTests/DayTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DayTests.swift 3 | // SwiftCron 4 | // 5 | // Created by Keegan Rush on 2016/05/06. 6 | // Copyright © 2016 Rush42. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | import SwiftCron 11 | 12 | class DayTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testEvery8thDayOfMonth() { 25 | let calendar = Calendar.current 26 | 27 | let dateToTestFrom = TestData.may11 28 | 29 | let every8thDayCron = CronExpression(minute: "0", hour: "0", day: "8") 30 | let nextRunDate = every8thDayCron?.getNextRunDate(dateToTestFrom) 31 | 32 | XCTAssertTrue(calendar.isDate(TestData.june8, inSameDayAs: nextRunDate!)) 33 | } 34 | 35 | func testLastDayOfMonthInFeb2016Returns28() { 36 | let dateToTestFrom = TestData.feb1Of2016 37 | 38 | let cronExpressionUnderTest = CronExpression(day: "L", month: 2, year: 2016)! 39 | 40 | let expectedNextRunDate = TestData.feb28Of2016 41 | let nextRunDate = cronExpressionUnderTest.getNextRunDate(dateToTestFrom)! 42 | XCTAssertTrue(Calendar.current.isDate(expectedNextRunDate, inSameDayAs: nextRunDate)) 43 | } 44 | 45 | func testLastDayOfMonthInMay2016Returns31() { 46 | let dateToTestFrom = TestData.may15Of2016 47 | 48 | let cronExpressionUnderTest = CronExpression(day: "L", month: 5, year: 2016)! 49 | 50 | let expectedNextRunDate = TestData.may31Of2016 51 | let nextRunDate = cronExpressionUnderTest.getNextRunDate(dateToTestFrom)! 52 | XCTAssertTrue(Calendar.current.isDate(expectedNextRunDate, inSameDayAs: nextRunDate)) 53 | } 54 | 55 | func testLastDayOfMonthInJune2016Returns30() { 56 | let dateToTestFrom = TestData.june1 57 | 58 | let cronExpressionUnderTest = CronExpression(day: "L", month: 6, year: 2016)! 59 | 60 | let expectedNextRunDate = TestData.june30Of2016 61 | let nextRunDate = cronExpressionUnderTest.getNextRunDate(dateToTestFrom)! 62 | XCTAssertTrue(Calendar.current.isDate(expectedNextRunDate, inSameDayAs: nextRunDate)) 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /Example/SwiftCronExampleTests/DescriptionTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DescriptionTests.swift 3 | // SwiftCronExample 4 | // 5 | // Created by Keegan Rush on 2016/05/10. 6 | // Copyright © 2016 Rush42. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | import SwiftCron 11 | 12 | class DescriptionTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | // * * * * * * 25 | func testDescriptionOfEveryMinute() { 26 | let cronExpression = CronExpression(minute: "*")! 27 | 28 | let description = cronExpression.shortDescription 29 | let expectedDescription = "Every minute" 30 | XCTAssertEqual(description, expectedDescription) 31 | 32 | let longDescription = cronExpression.longDescription 33 | XCTAssertEqual(longDescription, expectedDescription) 34 | } 35 | 36 | // func testDescriptionOfEveryMinuteIn2017() { 37 | // let cronExpression = CronExpression(cronString: "* * * * * 2017")! 38 | // 39 | // let description = cronExpression.shortDescription 40 | // let expectedDescription = "Every minute" 41 | // XCTAssertEqual(description, expectedDescription) 42 | // 43 | // let longDescription = cronExpression.longDescription 44 | // XCTAssertEqual(longDescription, expectedDescription) 45 | // } 46 | // 47 | // func testDescriptionOfEveryMinuteIn2017a() { 48 | // let cronExpression = CronExpression(cronString: "* 2 * * * 2017")! 49 | // 50 | // let description = cronExpression.shortDescription 51 | // let expectedDescription = "Every minute" 52 | // XCTAssertEqual(description, expectedDescription) 53 | // 54 | // let longDescription = cronExpression.longDescription 55 | // XCTAssertEqual(longDescription, expectedDescription) 56 | // } 57 | // 58 | // func testDescriptionOfEveryMinuteIn2017b() { 59 | // let cronExpression = CronExpression(cronString: "2 * * * * 2017")! 60 | // 61 | // let description = cronExpression.shortDescription 62 | // let expectedDescription = "Every minute" 63 | // XCTAssertEqual(description, expectedDescription) 64 | // 65 | // let longDescription = cronExpression.longDescription 66 | // XCTAssertEqual(longDescription, expectedDescription) 67 | // } 68 | 69 | // 0 12 * * * * 70 | func testDescriptionOfEveryDayAtMidday() { 71 | let cronExpression = CronExpression(minute: "0", hour: "12")! 72 | 73 | let description = cronExpression.shortDescription 74 | let expectedDescription = "Every day" 75 | XCTAssertEqual(description, expectedDescription) 76 | 77 | let longDescription = cronExpression.longDescription 78 | let expectedLongDescription = "Every day at 12:00" 79 | XCTAssertEqual(longDescription, expectedLongDescription) 80 | } 81 | 82 | // 0 0 14 * * * 83 | func testDescriptionOfEveryMonthOn14th() { 84 | let cronExpression = CronExpression(minute: "0", hour: "0", day: "14")! 85 | 86 | let description = cronExpression.shortDescription 87 | let expectedDescription = "Every 14th of the month" 88 | XCTAssertEqual(description, expectedDescription) 89 | 90 | let longDesc = cronExpression.longDescription 91 | let expectedLongDesc = "Every 14th of the month at 00:00" 92 | XCTAssertEqual(longDesc, expectedLongDesc) 93 | } 94 | 95 | // 0 0 14 2 * * 96 | func testDescriptionOfEveryYearFeb14th() { 97 | let cronExpression = CronExpression(minute: "0", hour: "0", day: "14", month: "2")! 98 | 99 | let description = cronExpression.shortDescription 100 | let expectedDescription = "Every 14th of February" 101 | XCTAssertEqual(description, expectedDescription) 102 | 103 | let longDesc = cronExpression.longDescription 104 | let expectedLongDesc = "Every 14th of February at 00:00" 105 | XCTAssertEqual(longDesc, expectedLongDesc) 106 | } 107 | 108 | // 0 0 13 * 6 * 109 | func testDescriptionOfEveryFriday13th() { 110 | let cronExpression = CronExpression(minute: "0", hour: "0", day: "13", weekday: "5")! 111 | 112 | let description = cronExpression.shortDescription 113 | let expectedDescription = "Every Friday the 13th" 114 | XCTAssertEqual(description, expectedDescription) 115 | 116 | let longDesc = cronExpression.longDescription 117 | let expectedLongDesc = "Every Friday the 13th at 00:00" 118 | XCTAssertEqual(longDesc, expectedLongDesc) 119 | } 120 | 121 | // 0 0 * * 2,3,4,5,6 * 122 | func testDescriptionOfWeekdays() { 123 | let cronExpression = CronExpression(minute: "0", hour: "0", weekday: "1,2,3,4,5")! 124 | 125 | let description = cronExpression.shortDescription 126 | let expectedDescription = "Every weekday" 127 | XCTAssertEqual(description, expectedDescription) 128 | 129 | let longDesc = cronExpression.longDescription 130 | let expectedLongDesc = "Every weekday at 00:00" 131 | XCTAssertEqual(longDesc, expectedLongDesc) 132 | } 133 | 134 | // 0 12 * * 1,7 * 135 | func testDescriptionOfWeekend() { 136 | let cronExpression = CronExpression(minute: "0", hour: "12", weekday: "6,7")! 137 | 138 | let description = cronExpression.shortDescription 139 | let expectedDescription = "Every Saturday, Sunday" 140 | XCTAssertEqual(description, expectedDescription) 141 | 142 | let longDesc = cronExpression.longDescription 143 | let expectedLongDesc = "Every Saturday, Sunday at 12:00" 144 | XCTAssertEqual(longDesc, expectedLongDesc) 145 | } 146 | 147 | // * * * * 2 * 148 | func testDescriptionOfOnlyWeekdaySpecified() { 149 | let cronExpression = CronExpression(weekday: "1")! 150 | 151 | let description = cronExpression.shortDescription 152 | let expectedDescription = "Every minute on a Monday" 153 | XCTAssertEqual(description, expectedDescription) 154 | 155 | let longDesc = cronExpression.longDescription 156 | XCTAssertEqual(longDesc, expectedDescription) 157 | } 158 | 159 | // 0 0 11 5 * 2026 160 | func testDescriptionOfMay112016() { 161 | let cronExpression = CronExpression(minute: "0", hour: "0", day: "11", month: "5", year: "2026")! 162 | 163 | let description = cronExpression.shortDescription 164 | let expectedDescription = "11th of May 2026" 165 | XCTAssertEqual(description, expectedDescription) 166 | 167 | let longDesc = cronExpression.longDescription 168 | let expectedLongDesc = "11th of May 2026 at 00:00" 169 | XCTAssertEqual(longDesc, expectedLongDesc) 170 | } 171 | 172 | // 0 0 * * 1,3 * 173 | func testDescriptionOfMondayAndWednesday() { 174 | let cronExpression = CronExpression(minute: "0", hour: "0", weekday: "1,3")! 175 | 176 | let description = cronExpression.shortDescription 177 | let expectedDescription = "Every Monday, Wednesday" 178 | XCTAssertEqual(description, expectedDescription) 179 | 180 | let longDesc = cronExpression.longDescription 181 | let expectedLongDesc = "Every Monday, Wednesday at 00:00" 182 | XCTAssertEqual(longDesc, expectedLongDesc) 183 | } 184 | 185 | // 30 * 11 * * * 186 | func testEveryHourAt30MinutesOn11thOfTheMonth() { 187 | let cronExpression = CronExpression(minute: "30", day: "11")! 188 | 189 | let description = cronExpression.shortDescription 190 | let expectedDescription = "Every hour at 30 minutes on the 11th" 191 | XCTAssertEqual(description, expectedDescription) 192 | 193 | let longDesc = cronExpression.longDescription 194 | XCTAssertEqual(longDesc, expectedDescription) 195 | } 196 | 197 | func testEveryWeekdayAtEvery30MinutesOnATuesday() { 198 | let cronExpression = CronExpression(minute: "30", weekday: "2")! 199 | 200 | let description = cronExpression.shortDescription 201 | let expectedDescription = "Every 30 minutes on a Tuesday" 202 | XCTAssertEqual(description, expectedDescription) 203 | 204 | let longDesc = cronExpression.longDescription 205 | XCTAssertEqual(longDesc, expectedDescription) 206 | } 207 | 208 | } 209 | -------------------------------------------------------------------------------- /Example/SwiftCronExampleTests/Field Specific Tests/MonthFieldTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MonthFieldTests.swift 3 | // SwiftCronExample 4 | // 5 | // Created by Keegan Rush on 2016/09/22. 6 | // Copyright © 2016 Rush42. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | @testable import SwiftCron 11 | 12 | class MonthFieldTests: XCTestCase { 13 | 14 | func testThatIncrementingAddsOneMonthWhenItCantMatchValue() { 15 | let dateToTest = DateBuilder().with(month: 4).with(year: 2016).build() 16 | 17 | let monthField = MonthField() 18 | let valueToMatch = "13" 19 | let actualDate = monthField.increment(dateToTest, toMatchValue: valueToMatch) 20 | 21 | let expectedDate = DateBuilder().with(month: 5).with(year: 2016).build() 22 | 23 | XCTAssertEqual(expectedDate, actualDate) 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /Example/SwiftCronExampleTests/HourTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // HourTests.swift 3 | // SwiftCron 4 | // 5 | // Created by Keegan Rush on 2016/05/06. 6 | // Copyright © 2016 Rush42. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | import SwiftCron 11 | 12 | class HourTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testEvery11thHour() { 25 | let calendar = Calendar.current 26 | 27 | let dateToTestFrom = TestData.may11 28 | 29 | var components = calendar.dateComponents([.day, .year, .month, .hour], from: dateToTestFrom) 30 | components.hour = 11 31 | let expectedDate = calendar.date(from: components) 32 | 33 | let every11thHourCron = CronExpression(minute: "0", hour: "11") 34 | let nextRunDate = every11thHourCron?.getNextRunDate(dateToTestFrom) 35 | 36 | XCTAssertTrue(calendar.isDate(nextRunDate!, equalTo: expectedDate!, toGranularity: .hour)) 37 | } 38 | 39 | func testEverySecondAndEveryFourthHourOfDay() { 40 | let dateToTestFrom = TestData.may15Of2016 41 | 42 | let everySecondAndFourthHourOfDayCron = CronExpression(minute: "0", hour: "2,4")! 43 | 44 | let calendar = Calendar.current 45 | var components = calendar.dateComponents([.day, .year, .month, .hour], from: dateToTestFrom) 46 | components.hour! += 2 47 | let expectedNextRunDate = calendar.date(from: components)! 48 | var nextRunDate = everySecondAndFourthHourOfDayCron.getNextRunDate(dateToTestFrom)! 49 | XCTAssertTrue(calendar.isDate(nextRunDate, equalTo: expectedNextRunDate, toGranularity: .hour)) 50 | 51 | components.hour! += 2 52 | let expectedFollowingRunDate = calendar.date(from: components)! 53 | nextRunDate = everySecondAndFourthHourOfDayCron.getNextRunDate(addMinuteTo(date: nextRunDate))! 54 | XCTAssertTrue(calendar.isDate(nextRunDate, equalTo: expectedFollowingRunDate, toGranularity: .hour)) 55 | 56 | components.hour! = 2 57 | components.day! += 1 58 | let expectedFinalRunDate = calendar.date(from: components)! 59 | nextRunDate = everySecondAndFourthHourOfDayCron.getNextRunDate(addMinuteTo(date: nextRunDate))! 60 | XCTAssertTrue(calendar.isDate(nextRunDate, equalTo: expectedFinalRunDate, toGranularity: .hour)) 61 | } 62 | 63 | func addMinuteTo(date: Date) -> Date { 64 | let calendar = Calendar.current 65 | var components = calendar.dateComponents([.day, .year, .month, .hour, .minute], from: date) 66 | components.minute! += 1 67 | return calendar.date(from: components)! 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /Example/SwiftCronExampleTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /Example/SwiftCronExampleTests/MinuteTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MinuteTests.swift 3 | // SwiftCron 4 | // 5 | // Created by Keegan Rush on 2016/05/06. 6 | // Copyright © 2016 Rush42. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | import SwiftCron 11 | 12 | class MinuteTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testEvery30thMinute() { 25 | let calendar = Calendar.current 26 | 27 | let dateToTestFrom = TestData.may11 28 | 29 | var components = calendar.dateComponents([.day, .year, .month, .hour], from: dateToTestFrom) 30 | components.minute = 30 31 | let expectedDate = calendar.date(from: components) 32 | 33 | let every30thMinuteCron = CronExpression(minute: "30") 34 | let nextRunDate = every30thMinuteCron?.getNextRunDate(dateToTestFrom) 35 | 36 | XCTAssertTrue(calendar.isDate(nextRunDate!, equalTo: expectedDate!, toGranularity: .minute)) 37 | } 38 | 39 | func testEvery15thAnd45thMinutes() { 40 | let dateToTestFrom = TestData.may11 41 | 42 | let every15thand45thMinuteCron = CronExpression(minute: "15,45")! 43 | 44 | let calendar = Calendar.current 45 | var components = calendar.dateComponents([.day, .year, .month, .hour, .minute], from: dateToTestFrom) 46 | components.minute! += 15 47 | let expectedNextRunDate = calendar.date(from: components)! 48 | var nextRunDate = every15thand45thMinuteCron.getNextRunDate(dateToTestFrom)! 49 | XCTAssertTrue(calendar.isDate(nextRunDate, equalTo: expectedNextRunDate, toGranularity: .minute)) 50 | 51 | components.minute! += 30 52 | let expectedFollowingRunDate = calendar.date(from: components)! 53 | nextRunDate = every15thand45thMinuteCron.getNextRunDate(addMinuteTo(date: nextRunDate))! 54 | XCTAssertTrue(calendar.isDate(nextRunDate, equalTo: expectedFollowingRunDate, toGranularity: .minute)) 55 | } 56 | 57 | func addMinuteTo(date: Date) -> Date { 58 | let calendar = Calendar.current 59 | var components = calendar.dateComponents([.day, .year, .month, .hour, .minute], from: date) 60 | components.minute! += 1 61 | return calendar.date(from: components)! 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /Example/SwiftCronExampleTests/MonthTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MonthTests.swift 3 | // SwiftCron 4 | // 5 | // Created by Keegan Rush on 2016/05/06. 6 | // Copyright © 2016 Rush42. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | import SwiftCron 11 | 12 | class MonthTests: XCTestCase { 13 | 14 | func testEveryMonthOn1stRunsNextMonth() { 15 | let calendar = Calendar.current 16 | 17 | let dateToTestFrom = TestData.may11 18 | 19 | let firstDayOfMonthCron = CronExpression(minute: "0", hour: "0", day: "1") 20 | let nextRunDate = firstDayOfMonthCron?.getNextRunDate(dateToTestFrom) 21 | 22 | XCTAssertTrue(calendar.isDate(TestData.june1, inSameDayAs: nextRunDate!)) 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /Example/SwiftCronExampleTests/SwiftCronExampleTests-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | // 2 | // Use this file to import your target's public headers that you would like to expose to Swift. 3 | // 4 | 5 | -------------------------------------------------------------------------------- /Example/SwiftCronExampleTests/SwiftCronExampleTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SwiftCronExampleTests.swift 3 | // SwiftCronExampleTests 4 | // 5 | // Created by Keegan Rush on 2016/05/10. 6 | // Copyright © 2016 Rush42. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | @testable import SwiftCronExample 11 | 12 | class SwiftCronExampleTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testExample() { 25 | // This is an example of a functional test case. 26 | // Use XCTAssert and related functions to verify your tests produce the correct results. 27 | } 28 | 29 | func testPerformanceExample() { 30 | // This is an example of a performance test case. 31 | self.measureBlock { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /Example/SwiftCronExampleTests/SwiftCronTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SwiftCronTests.swift 3 | // SwiftCronTests 4 | // 5 | // Created by Keegan Rush on 2016/05/05. 6 | // Copyright © 2016 Rush42. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | import SwiftCron 11 | 12 | class SwiftCronTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testGetCronWithValidExpression() { 25 | let cron = CronExpression(cronString: "1 * * * * *") 26 | XCTAssertNotNil(cron) 27 | } 28 | 29 | func testGetCronWithInvalidExpression() { 30 | let cron = CronExpression(cronString: "foo") 31 | XCTAssertNil(cron) 32 | } 33 | 34 | func testPerformance() { 35 | measure({ 36 | let cron = CronExpression(cronString: "32 4 8 12 3 *") 37 | var runDate: Date? 38 | 39 | runDate = cron?.getNextRunDate(TestData.janFirst2017) 40 | XCTAssertNotNil(runDate) 41 | }) 42 | 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /Example/SwiftCronExampleTests/Test Data/TestData.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TestData.swift 3 | // SwiftCron 4 | // 5 | // Created by Keegan Rush on 2016/05/06. 6 | // Copyright © 2016 Rush42. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | class TestData { 12 | static let may11 = (Calendar.current as NSCalendar) 13 | .date(era: 1, year: 2016, month: 05, day: 11, hour: 0, minute: 0, second: 0, nanosecond: 0)! 14 | static let may12 = (Calendar.current as NSCalendar) 15 | .date(era: 1, year: 2016, month: 05, day: 12, hour: 0, minute: 0, second: 0, nanosecond: 0)! 16 | static let may14 = (Calendar.current as NSCalendar) 17 | .date(era: 1, year: 2016, month: 05, day: 14, hour: 0, minute: 0, second: 0, nanosecond: 0)! 18 | static let may16 = (Calendar.current as NSCalendar) 19 | .date(era: 1, year: 2016, month: 05, day: 16, hour: 0, minute: 0, second: 0, nanosecond: 0)! 20 | static let june1 = (Calendar.current as NSCalendar) 21 | .date(era: 1, year: 2016, month: 06, day: 1, hour: 0, minute: 0, second: 0, nanosecond: 0)! 22 | static let june8 = (Calendar.current as NSCalendar) 23 | .date(era: 1, year: 2016, month: 06, day: 8, hour: 0, minute: 0, second: 0, nanosecond: 0)! 24 | static let janFirst2017 = (Calendar.current as NSCalendar) 25 | .date(era: 1, year: 2017, month: 01, day: 1, hour: 0, minute: 0, second: 0, nanosecond: 0)! 26 | } 27 | -------------------------------------------------------------------------------- /Example/SwiftCronExampleTests/TestData.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TestData.swift 3 | // SwiftCron 4 | // 5 | // Created by Keegan Rush on 2016/05/06. 6 | // Copyright © 2016 Rush42. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | class TestData { 12 | static let feb28Of2016 = DateBuilder().with(year: 2016).with(month: 2).with(day: 28).build() 13 | static let feb1Of2016 = DateBuilder().with(year: 2016).with(month: 2).with(day: 1).build() 14 | static let may15Of2016 = DateBuilder().with(year: 2016).with(month: 5).with(day: 15).build() 15 | static let may31Of2016 = DateBuilder().with(year: 2016).with(month: 5).with(day: 31).build() 16 | static let june30Of2016 = DateBuilder().with(year: 2016).with(month: 6).with(day: 30).build() 17 | static let july11Of2016 = DateBuilder().with(year: 2016).with(month: 7).with(day: 11).build() 18 | static let july27Of2016 = DateBuilder().with(year: 2016).with(month: 7).with(day: 27).build() 19 | static let may11 = DateBuilder().with(year: 2016).with(month: 5).with(day: 11).build() 20 | static let may12 = DateBuilder().with(year: 2016).with(month: 5).with(day: 12).build() 21 | static let may14 = DateBuilder().with(year: 2016).with(month: 5).with(day: 14).build() 22 | static let may16 = DateBuilder().with(year: 2016).with(month: 5).with(day: 16).build() 23 | static let june1 = DateBuilder().with(year: 2016).with(month: 6).with(day: 1).build() 24 | static let june8 = DateBuilder().with(year: 2016).with(month: 6).with(day: 8).build() 25 | static let janFirst2017 = DateBuilder().with(year: 2017).with(month: 1).with(day: 1).build() 26 | } 27 | -------------------------------------------------------------------------------- /Example/SwiftCronExampleTests/Tests.swift: -------------------------------------------------------------------------------- 1 | // https://github.com/Quick/Quick 2 | 3 | import Quick 4 | import Nimble 5 | import SwiftCron 6 | 7 | class TableOfContentsSpec: QuickSpec { 8 | override func spec() { 9 | describe("these will fail") { 10 | 11 | it("can do maths") { 12 | expect(1) == 2 13 | } 14 | 15 | it("can read") { 16 | expect("number") == "string" 17 | } 18 | 19 | it("will eventually fail") { 20 | expect("time").toEventually(equal("done")) 21 | } 22 | 23 | context("these will pass") { 24 | 25 | it("can do maths") { 26 | expect(23) == 23 27 | } 28 | 29 | it("can read") { 30 | expect("🐮") == "🐮" 31 | } 32 | 33 | it("will eventually pass") { 34 | var time = "passing" 35 | 36 | dispatch_async(dispatch_get_main_queue()) { 37 | time = "done" 38 | } 39 | 40 | waitUntil { done in 41 | NSThread.sleepForTimeInterval(0.5) 42 | expect(time) == "done" 43 | 44 | done() 45 | } 46 | } 47 | } 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Example/SwiftCronExampleTests/TimeZoneTests.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | import SwiftCron 3 | 4 | class TimeZoneTests: XCTestCase { 5 | 6 | func testTimeZoneDifferencesResultInVariationOfNextRunDate() { 7 | let newYorkTZ = TimeZone(identifier: "America/New_York")! 8 | let losAngelesTZ = TimeZone(identifier: "America/Los_Angeles")! 9 | 10 | let cronExpression = CronExpression(cronString: "0 10 12 9 * *")! 11 | 12 | let nextRunNewYorkTZ = cronExpression.getNextRunDateFromNow(adjustingForTimeZone: newYorkTZ)! 13 | let nextRunLosAngelesTZ = cronExpression.getNextRunDateFromNow(adjustingForTimeZone: losAngelesTZ)! 14 | 15 | let milliDiff = nextRunLosAngelesTZ.timeIntervalSince1970 - nextRunNewYorkTZ.timeIntervalSince1970 16 | let hourDiff = milliDiff / (60*60) 17 | 18 | let expectedTimezoneOffset: Double = 3 19 | XCTAssertEqual(expectedTimezoneOffset, hourDiff) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Example/SwiftCronExampleTests/WeekdayTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // WeekdayTests.swift 3 | // SwiftCron 4 | // 5 | // Created by Keegan Rush on 2016/05/06. 6 | // Copyright © 2016 Rush42. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | import SwiftCron 11 | 12 | class WeekdayTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testEveryWeekOnMonday() { 25 | let calendar = Calendar.current 26 | let dateToTestFrom = TestData.may11 27 | let nextMonday = TestData.may16 28 | 29 | let everyMondayCron = CronExpression(minute: "0", hour: "0", weekday: "1") 30 | let nextRunDate = everyMondayCron?.getNextRunDate(dateToTestFrom) 31 | 32 | XCTAssertTrue(calendar.isDate(nextMonday, inSameDayAs: nextRunDate!)) 33 | } 34 | 35 | func testEveryWeekday() { 36 | let calendar = Calendar.current 37 | let weekendDateToTestFrom = TestData.may14 38 | let nextMonday = TestData.may16 39 | 40 | let everyWeekdayCron = CronExpression(cronString: "0 0 * * 1,2,3,4,5 *") 41 | let nextRunDateFromWeekend = everyWeekdayCron?.getNextRunDate(weekendDateToTestFrom) 42 | 43 | XCTAssertTrue(calendar.isDate(nextMonday, inSameDayAs: nextRunDateFromWeekend!)) 44 | 45 | var wednesday = TestData.may11 46 | // Add a minute to ensure we're not at midnight to prevent a match for wednesday 47 | wednesday = calendar.date(byAdding: .minute, value: 1, to: wednesday)! 48 | let thursday = TestData.may12 49 | let nextRunDateFromWednesday = everyWeekdayCron?.getNextRunDate(wednesday) 50 | XCTAssertTrue(calendar.isDate(thursday, inSameDayAs: nextRunDateFromWednesday!)) 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Example/SwiftCronExampleTests/YearTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // YearTests.swift 3 | // SwiftCron 4 | // 5 | // Created by Keegan Rush on 2016/05/06. 6 | // Copyright © 2016 Rush42. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | import SwiftCron 11 | 12 | class YearTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testEveryYearOn1stJanRunsNextYear() { 25 | let calendar = Calendar.current 26 | 27 | let dateToTestFrom = TestData.may11 28 | 29 | let firstDayOfMonthCron = CronExpression(minute: "0", hour: "0", day: "1", month: "1") 30 | let nextRunDate = firstDayOfMonthCron?.getNextRunDate(dateToTestFrom) 31 | 32 | XCTAssertTrue(calendar.isDate(TestData.janFirst2017, inSameDayAs: nextRunDate!)) 33 | } 34 | 35 | func testEveryThursdayIn2018RunsIn2018() { 36 | let thursdaysIn2018Cron = CronExpression(minute: "0", hour: "0", weekday: "4", year: "2018")! 37 | let dateToTestFrom = TestData.may15Of2016 38 | let firstThursdayIn2018 = DateBuilder().with(day: 4).with(month: 1).with(year: 2018).build() 39 | let nextRunDate = thursdaysIn2018Cron.getNextRunDate(dateToTestFrom)! 40 | XCTAssertTrue(Calendar.current.isDate(firstThursdayIn2018, inSameDayAs: nextRunDate)) 41 | } 42 | 43 | func testNextRunDateIsNilWhenDateIsInPast() { 44 | let dateToTestFrom = DateBuilder().with(month: 5).with(year: 2015).build() 45 | 46 | let firstDayOfFirstMonthInPastCron = CronExpression(minute: "0", hour: "0", day: "1", month: "1", year: "2014") 47 | let nextRunDate = firstDayOfFirstMonthInPastCron?.getNextRunDate(dateToTestFrom) 48 | 49 | XCTAssertNil(nextRunDate) 50 | } 51 | 52 | func testNextRunDateIsNilWhenDateIsNotInReasonableFuture() { 53 | let dateToTestFrom = DateBuilder().with(month: 5).with(year: 2015).build() 54 | 55 | let firstDayOfFirstMonthInPastCron = 56 | CronExpression(minute: "0", hour: "0", day: "1", month: "1", year: "999999") 57 | let nextRunDate = firstDayOfFirstMonthInPastCron?.getNextRunDate(dateToTestFrom) 58 | 59 | XCTAssertNil(nextRunDate) 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 Keegan Rush galaxyplansoftware@gmail.com 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.0 2 | // The swift-tools-version declares the minimum version of Swift required to build this package. 3 | import PackageDescription 4 | 5 | let package = Package( 6 | name: "SwiftCron", 7 | products: [ 8 | .library(name: "SwiftCron", targets: ["SwiftCron"]), 9 | ], 10 | dependencies:[], 11 | targets: [ 12 | .target(name: "SwiftCron", dependencies: [], path: "Sources/") 13 | ], 14 | swiftLanguageVersions: [.v5] 15 | ) 16 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | SwiftCron 2 | ============== 3 | [![codecov](https://codecov.io/gh/TheCodedSelf/SwiftCron/branch/master/graph/badge.svg)](https://codecov.io/gh/TheCodedSelf/SwiftCron) [![CocoaPod Version](https://img.shields.io/cocoapods/v/SwiftCron.svg)](http://cocoapods.org/pods/SwiftCron) 4 | 5 | A cron expression parser that can take a cron string and give you the next run date and time specified in the string. 6 | 7 |
8 | 9 | ## Installation 10 | ### CocoaPods 11 | 12 | Podfile: 13 | 14 | ```ruby 15 | pod 'SwiftCron' 16 | ``` 17 | 18 | ### Carthage 19 | 20 | Cartfile: 21 | 22 | ``` 23 | github "thecodedself/swiftcron" >= 0.4.5 24 | ``` 25 | 26 | ### Swift Package Manager 27 | 28 | Package.swift: 29 | 30 | ``` 31 | .Package(url: "https://github.com/TheCodedSelf/SwiftCron.git", majorVersion: 0) 32 | ``` 33 | 34 | ## Requirements 35 | 36 | - iOS 9.0 or greater 37 | - Xcode 8.0 or greater 38 | - Swift 3 or greater 39 | 40 | Usage 41 | -------- 42 | ##### Create a Cron Expression 43 | Creating a cron expression is easy. Just invoke the initializer with the fields you want. 44 | ```swift 45 | // Midnight every 8th day of the month 46 | let myCronExpression = CronExpression(minute: "0", hour: "0", day: "8") 47 | ``` 48 | ```swift 49 | // Executes May 9th, 2024 at 11:30am 50 | let anotherExpression = CronExpression(minute: "30", hour: "11", day: "9", month: "5", year: "2024") 51 | ``` 52 | ```swift 53 | // Every tuesday at 6:00pm 54 | let everyTuesday = CronExpression(minute: "0", hour: "18", weekday: "2") 55 | ``` 56 | 57 |
58 | 59 | ##### Manually create an expression 60 | 61 | If you'd like to manually write the expression yourself, The cron format is as follows: 62 | 63 | > \* \* \* \* \* \* 64 |
(Minute) (Hour) (Day) (Month) (Weekday) (Year) 65 | 66 | Initialize an instance of CronExpression with a string specifying the format. 67 | 68 | ```swift 69 | // Every 11th May at midnight 70 | let every11May = CronExpression(cronString: "0 0 11 5 * *") 71 | ``` 72 | 73 |
74 | 75 | ##### Get the next run date 76 | 77 | Once you have your CronExpression, you can get the next time the cron will run. Call the getNextRunDate(_:) method and pass in the date to begin the search on. 78 | 79 | ```swift 80 | // Every Friday 13th at midday 81 | let myCronExpression = CronExpression(minute: "0", hour: "12", day: "13", weekday: "5") 82 | 83 | let dateToStartSearchOn = NSDate() 84 | let nextRunDate = myCronExpression.getNextRunDate(dateToStartSearchOn) 85 | ``` 86 | 87 | ##### Custom timezones 88 | 89 | By default SwiftCron uses the system's current timezone to calculate the next run date. To override this behavior, just pass the timezone you want into `CronExpression.getNextRunDateFromNow(adjustingForTimeZone:)` or `CronExpression.getNextRunDate(_:adjustingForTimeZone:)` methods. 90 | 91 | ```swift 92 | // Every 12th September at 10 AM 93 | let cronExpression = CronExpression(cronString: "0 10 12 9 * *") 94 | 95 | // Calculate the next run date as if the cron expression was created in the 96 | // America/Los_Angeles timezone 97 | let losAngeles = TimeZone(identifier: "America/Los_Angeles")! 98 | let nextRun = cronExpression.getNextRunDateFromNow(adjustingForTimeZone: losAngeles) 99 | ``` 100 | 101 | ## Contributing 102 | 103 | - Pull requests for bug fixes and new features are most welcome. 104 | - Pull requests will only be merged once the Travis CI build passes. 105 | 106 | -------------------------------------------------------------------------------- /Sources/CronDescriptionBuilder.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CronDescriptionBuilder.swift 3 | // Pods 4 | // 5 | // Created by Keegan Rush on 2016/05/10. 6 | // 7 | // 8 | 9 | import Foundation 10 | 11 | enum CronDescriptionLength { case short, long } 12 | 13 | class CronDescriptionBuilder { 14 | static let EveryWeekday: String = { 15 | let cronExp = CronExpression(cronString: "0 0 * * 1,2,3,4,5 *")! 16 | return DateFormatter.convertStringToDaysOfWeek(cronExp.cronRepresentation.weekday) 17 | }() 18 | 19 | static let EveryDay: String = { 20 | let cronExp = CronExpression(cronString: "0 0 * * 1,2,3,4,5,6,7 *")! 21 | return DateFormatter.convertStringToDaysOfWeek(cronExp.cronRepresentation.weekday) 22 | }() 23 | 24 | static func buildDescription(_ cronRepresentation: CronRepresentation, length: CronDescriptionLength) -> String { 25 | if let biggestField = cronRepresentation.biggestField { 26 | switch biggestField { 27 | case .minute: 28 | return descriptionWithMinuteBiggest(cronRepresentation, length: length) 29 | case .hour: 30 | return descriptionWithHourBiggest(cronRepresentation, length: length) 31 | case .day: 32 | return descriptionWithDayBiggest(cronRepresentation, length: length) 33 | case .month: 34 | return descriptionWithMonthBiggest(cronRepresentation, length: length) 35 | case .weekday: 36 | break 37 | case .year: 38 | return descriptionWithYearBiggest(cronRepresentation, length: length) 39 | } 40 | } 41 | return descriptionWithNoneBiggest(cronRepresentation, length: length) 42 | } 43 | 44 | private static func descriptionWithNoneBiggest(_ cronRepresentation: CronRepresentation, length: CronDescriptionLength) -> String { 45 | if CronRepresentation.isDefault(cronRepresentation.weekday) { 46 | return "Every minute" 47 | } else { 48 | let weekday = DateFormatter.convertStringToDaysOfWeek(cronRepresentation.weekday) 49 | return "Every minute on a \(weekday)" 50 | } 51 | } 52 | 53 | private static func descriptionWithMinuteBiggest(_ cronRepresentation: CronRepresentation, length: CronDescriptionLength) -> String { 54 | let minutes = DateFormatter.minuteStringWithMinute(cronRepresentation.minute) 55 | if CronRepresentation.isDefault(cronRepresentation.weekday) { 56 | return "Every hour at \(minutes) minutes" 57 | } else { 58 | let weekday = DateFormatter.convertStringToDaysOfWeek(cronRepresentation.weekday) 59 | return "Every \(minutes) minutes on a \(weekday)" 60 | } 61 | } 62 | 63 | private static func descriptionWithHourBiggest(_ cronRepresentation: CronRepresentation, length: CronDescriptionLength) -> String { 64 | 65 | let time = DateFormatter.timeStringWithHour(cronRepresentation.hour, minute: cronRepresentation.minute) 66 | 67 | if CronRepresentation.isDefault(cronRepresentation.weekday) { 68 | switch length { 69 | case .long: 70 | return "Every day at \(time)" 71 | case .short: 72 | return "Every day" 73 | } 74 | } else { 75 | let weekday = DateFormatter.convertStringToDaysOfWeek(cronRepresentation.weekday) 76 | var desc: String 77 | if weekday == EveryDay { 78 | desc = "Every day" 79 | } else if weekday == EveryWeekday { 80 | desc = "Every weekday" 81 | } else { 82 | desc = "Every \(weekday)" 83 | } 84 | switch length { 85 | case .long: 86 | return "\(desc) at \(time)" 87 | case .short: 88 | return desc 89 | } 90 | } 91 | 92 | } 93 | 94 | private static func descriptionWithDayBiggest(_ cronRepresentation: CronRepresentation, length: CronDescriptionLength) -> String { 95 | let day = Int(cronRepresentation.day)!.ordinal 96 | 97 | if CronRepresentation.isDefault(cronRepresentation.hour) { 98 | let minutes = DateFormatter.minuteStringWithMinute(cronRepresentation.minute) 99 | return "Every hour at \(minutes) minutes on the \(day)" 100 | } else { 101 | let time = DateFormatter.timeStringWithHour(cronRepresentation.hour, minute: cronRepresentation.minute) 102 | if CronRepresentation.isDefault(cronRepresentation.weekday) { 103 | switch length { 104 | case .long: 105 | return "Every \(day) of the month at \(time)" 106 | case .short: 107 | return "Every \(day) of the month" 108 | } 109 | } else { 110 | let weekday = DateFormatter.convertStringToDaysOfWeek(cronRepresentation.weekday) 111 | switch length { 112 | case .long: 113 | return "Every \(weekday) the \(day) at \(time)" 114 | case .short: 115 | return "Every \(weekday) the \(day)" 116 | } 117 | } 118 | } 119 | } 120 | 121 | private static func descriptionWithMonthBiggest(_ cronRepresentation: CronRepresentation, length: CronDescriptionLength) -> String { 122 | let time = DateFormatter.timeStringWithHour(cronRepresentation.hour, minute: cronRepresentation.minute) 123 | let day = Int(cronRepresentation.day)!.ordinal 124 | let month = Int(cronRepresentation.month)!.convertToMonth() 125 | 126 | let desc = "Every \(day) of \(month)" 127 | if CronRepresentation.isDefault(cronRepresentation.weekday) { 128 | switch length { 129 | case .long: 130 | return "\(desc) at \(time)" 131 | case .short: 132 | return desc 133 | } 134 | } else { 135 | let weekday = DateFormatter.convertStringToDaysOfWeek(cronRepresentation.weekday) 136 | switch length { 137 | case .short: 138 | return "Every \(weekday) the \(day) of \(month)" 139 | case .long: 140 | return "Every \(weekday) the \(day) of \(month) at \(time)" 141 | } 142 | } 143 | } 144 | 145 | private static func descriptionWithYearBiggest(_ cronRepresentation: CronRepresentation, length: CronDescriptionLength) -> String { 146 | let time = DateFormatter.timeStringWithHour(cronRepresentation.hour, minute: cronRepresentation.minute) 147 | let day = Int(cronRepresentation.day)!.ordinal 148 | let month = Int(cronRepresentation.month)!.convertToMonth() 149 | 150 | let desc = "\(day) of \(month) \(cronRepresentation.year)" 151 | if CronRepresentation.isDefault(cronRepresentation.weekday) { 152 | switch length { 153 | case .short: 154 | return desc 155 | case .long: 156 | return "\(desc) at \(time)" 157 | } 158 | } else { 159 | let weekday = DateFormatter.convertStringToDaysOfWeek(cronRepresentation.weekday) 160 | switch length { 161 | case .short: 162 | return "\(weekday) \(desc)" 163 | case .long: 164 | return "\(weekday) \(desc) at \(time)" 165 | } 166 | } 167 | } 168 | } 169 | -------------------------------------------------------------------------------- /Sources/CronExpression.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | /* 3 | * * * * * 4 | | | | | | 5 | | | | | ---- Weekday 6 | | | | ------ Month 7 | | | -------- Day 8 | | ---------- Hour 9 | ------------ Minute 10 | 11 | * * * * * * 12 | | | | | | | 13 | | | | | | ---- Year 14 | | | | | ------ Weekday 15 | | | | -------- Month 16 | | | ---------- Day 17 | | ------------ Hour 18 | -------------- Minute 19 | */ 20 | public class CronExpression { 21 | 22 | var cronRepresentation: CronRepresentation 23 | 24 | public convenience init?(cronString: String) { 25 | guard let cronRepresentation = CronRepresentation(cronString: cronString) else { 26 | return nil 27 | } 28 | self.init(cronRepresentation: cronRepresentation) 29 | } 30 | 31 | public convenience init?(minute: CronFieldTranslatable = CronRepresentation.DefaultValue, hour: CronFieldTranslatable = CronRepresentation.DefaultValue, day: CronFieldTranslatable = CronRepresentation.DefaultValue, month: CronFieldTranslatable = CronRepresentation.DefaultValue, weekday: CronFieldTranslatable = CronRepresentation.DefaultValue, year: CronFieldTranslatable = CronRepresentation.DefaultValue) { 32 | let cronRepresentation = CronRepresentation(minute: minute.cronFieldRepresentation, hour: hour.cronFieldRepresentation, day: day.cronFieldRepresentation, month: month.cronFieldRepresentation, weekday: weekday.cronFieldRepresentation, year: year.cronFieldRepresentation) 33 | self.init(cronRepresentation: cronRepresentation) 34 | } 35 | 36 | private init?(cronRepresentation theCronRepresentation: CronRepresentation) { 37 | cronRepresentation = theCronRepresentation 38 | 39 | let parts = cronRepresentation.cronParts 40 | for index: Int in 0 ..< parts.count { 41 | let field = CronField(rawValue: index)! 42 | if field.getFieldChecker().validate(parts[index]) == false { 43 | NSLog("\(#function): Invalid cron field value \(parts[index]) at position \(index)") 44 | return nil 45 | } 46 | } 47 | } 48 | 49 | public var stringRepresentation: String { 50 | return cronRepresentation.cronString 51 | } 52 | 53 | // MARK: - Description 54 | 55 | public var shortDescription: String { 56 | return CronDescriptionBuilder.buildDescription(cronRepresentation, length: .short) 57 | } 58 | 59 | public var longDescription: String { 60 | return CronDescriptionBuilder.buildDescription(cronRepresentation, length: .long) 61 | } 62 | 63 | // MARK: - Get Next Run Date 64 | 65 | public func getNextRunDateFromNow(adjustingForTimeZone outputTimeZone: TimeZone = .current) -> Date? { 66 | return getNextRunDate(Date(), adjustingForTimeZone: outputTimeZone) 67 | } 68 | 69 | public func getNextRunDate(_ date: Date, adjustingForTimeZone outputTimeZone: TimeZone = .current) -> Date? { 70 | guard let nextRun = getNextRunDate(date, skip: 0) else { return nil } 71 | return adjust(date: nextRun, for: outputTimeZone) 72 | } 73 | 74 | func adjust(date: Date, for timeZone: TimeZone) -> Date { 75 | let currentTZOffset = TimeZone.current.secondsFromGMT(for: date) 76 | let outputTZOffset = timeZone.secondsFromGMT(for: date) 77 | 78 | let tzDifference = TimeInterval(currentTZOffset - outputTZOffset) 79 | return date.addingTimeInterval(tzDifference) 80 | } 81 | 82 | func getNextRunDate(_ date: Date, skip: Int) -> Date? { 83 | guard matchIsTheoreticallyPossible(date) else { 84 | return nil 85 | } 86 | 87 | var timesToSkip = skip 88 | let calendar = Calendar.current 89 | var components = calendar.dateComponents([.year, .month, .day, .hour, .minute, .weekday], from: date) 90 | components.second = 0 91 | 92 | var nextRun = calendar.date(from: components)! 93 | 94 | // MARK: Issue 3: Instantiate enum instances with the right value 95 | let allFieldsInExpression: Array = [.minute, .hour, .day, .month, .weekday, .year] 96 | 97 | // Set a hard limit to bail on an impossible date 98 | iteration: for _: Int in 0 ..< 1000 { 99 | var satisfied = false 100 | 101 | currentFieldLoop: for cronField: CronField in allFieldsInExpression { 102 | // MARK: Issue 3: just call cronField.isSatisfiedBy, or getNextApplicableDate as specified in Issue 2 103 | let part = cronRepresentation[cronField.rawValue] 104 | let fieldChecker = cronField.getFieldChecker() 105 | 106 | if part.contains(CronRepresentation.ListIdentifier) == false { 107 | satisfied = fieldChecker.isSatisfiedBy(nextRun, value: part) 108 | } else { 109 | for listPart: String in part.components(separatedBy: CronRepresentation.ListIdentifier) { 110 | satisfied = fieldChecker.isSatisfiedBy(nextRun, value: listPart) 111 | if satisfied { 112 | break 113 | } 114 | } 115 | } 116 | 117 | // If the field is not satisfied, then start over 118 | if satisfied == false { 119 | nextRun = fieldChecker.increment(nextRun, toMatchValue: part) 120 | continue iteration 121 | } 122 | 123 | // Skip this match if needed 124 | if timesToSkip > 0 { 125 | _ = CronField(rawValue: 0)!.getFieldChecker().increment(nextRun, toMatchValue: part) 126 | timesToSkip -= 1 127 | } 128 | continue currentFieldLoop 129 | } 130 | return satisfied ? nextRun : nil 131 | } 132 | return nil 133 | } 134 | 135 | private func matchIsTheoreticallyPossible(_ date: Date) -> Bool { 136 | // TODO: Handle lists and steps 137 | guard let year = Int(cronRepresentation.year) else { 138 | return true 139 | } 140 | 141 | var components = DateComponents() 142 | components.year = year 143 | if let month = Int(cronRepresentation.month) { 144 | components.month = month 145 | 146 | if month < 1 { 147 | return false 148 | } 149 | } 150 | let day = Int(cronRepresentation.day) ?? Calendar.current.date(from: components)!.getLastDayOfMonth() 151 | //{ 152 | components.day = day 153 | 154 | if day < 1 { 155 | return false 156 | } 157 | //} 158 | let dateFromComponents = Calendar.current.date(from: components)! 159 | return date.compare(dateFromComponents) == .orderedAscending || date.compare(dateFromComponents) == .orderedSame 160 | } 161 | } 162 | -------------------------------------------------------------------------------- /Sources/CronFieldTranslatable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Keegan Rush on 2016/06/11. 3 | // 4 | 5 | import Foundation 6 | 7 | public protocol CronFieldTranslatable { 8 | var cronFieldRepresentation: String { get } 9 | } 10 | -------------------------------------------------------------------------------- /Sources/CronRepresentation.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CronRepresentation.swift 3 | // SwiftCron 4 | // 5 | // Created by Keegan Rush on 2016/05/06. 6 | // Copyright © 2016 Rush42. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | enum CronField: Int { 12 | case minute, hour, day, month, weekday, year 13 | private static let fieldCheckers: Array = [MinutesField(), HoursField(), DayOfMonthField(), MonthField(), DayOfWeekField(), YearField()] 14 | 15 | func getFieldChecker() -> FieldCheckerInterface { 16 | return CronField.fieldCheckers[rawValue] 17 | } 18 | } 19 | 20 | public struct CronRepresentation { 21 | static let NumberOfComponentsInValidString = 6 22 | public static let DefaultValue = "*" 23 | static let StepIdentifier = "/" 24 | static let ListIdentifier = "," 25 | static let RangeIdentifier = "-" 26 | 27 | var year: String 28 | var weekday: String 29 | var month: String 30 | var day: String 31 | var hour: String 32 | var minute: String 33 | 34 | var biggestField: CronField? { 35 | let defaultValue = CronRepresentation.DefaultValue 36 | 37 | if year != defaultValue { return CronField.year } 38 | if month != defaultValue { return CronField.month } 39 | if day != defaultValue { return CronField.day } 40 | if hour != defaultValue { return CronField.hour } 41 | if minute != defaultValue { return CronField.minute } 42 | return nil 43 | } 44 | 45 | // MARK: Issue 3: Get rid of. Should rather be using the enum 46 | subscript(index: Int) -> String { 47 | return cronParts[index] 48 | } 49 | 50 | init(minute: String = CronRepresentation.DefaultValue, hour: String = CronRepresentation.DefaultValue, day: String = CronRepresentation.DefaultValue, month: String = CronRepresentation.DefaultValue, weekday: String = CronRepresentation.DefaultValue, year: String = CronRepresentation.DefaultValue) { 51 | self.minute = minute 52 | self.hour = hour 53 | self.day = day 54 | self.month = month 55 | self.weekday = weekday 56 | self.year = year 57 | 58 | cronParts = [minute, hour, day, month, weekday, year] 59 | cronString = "\(minute) \(hour) \(day) \(month) \(weekday) \(year)" 60 | } 61 | 62 | init?(cronString: String) { 63 | let parts = cronString.components(separatedBy: " ") 64 | guard parts.count == CronRepresentation.NumberOfComponentsInValidString else { 65 | return nil 66 | } 67 | 68 | self.init(minute: parts[0], hour: parts[1], day: parts[2], month: parts[3], weekday: parts[4], year: parts[5]) 69 | } 70 | 71 | // MARK: Issue 3: pass in enum. Get value out of enum and check if it matches the default value? 72 | static func isDefault(_ field: String) -> Bool { 73 | return field == CronRepresentation.DefaultValue 74 | } 75 | 76 | public var cronString: String 77 | 78 | public var cronParts: Array 79 | } 80 | -------------------------------------------------------------------------------- /Sources/DayOfMonthField.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | class DayOfMonthField: Field, FieldCheckerInterface { 4 | func isSatisfiedBy(_ date: Date, value: String) -> Bool { 5 | let calendar = Calendar.current 6 | let components = calendar.dateComponents([.day, .month, .year], from: date) 7 | 8 | if value == "L" { 9 | return components.day == date.getLastDayOfMonth() 10 | } 11 | 12 | let day = components.day! 13 | return self.isSatisfied(String(day), value: value) 14 | } 15 | 16 | func increment(_ date: Date, toMatchValue: String) -> Date { 17 | if let nextDate = date.nextDate(matchingUnit: .day, value: toMatchValue) { 18 | return nextDate 19 | } 20 | 21 | let calendar = Calendar.current 22 | var midnightComponents = calendar.dateComponents([.year, .month, .day, .hour, .minute, .weekday], from: date) 23 | midnightComponents.hour = 0 24 | midnightComponents.minute = 0 25 | midnightComponents.second = 0 26 | 27 | var components = DateComponents() 28 | components.day = 1 29 | return calendar.date(byAdding: components, to: calendar.date(from: midnightComponents)!)! 30 | } 31 | 32 | func validate(_ value: String) -> Bool { 33 | return StringValidator.isAlphanumeric(value) 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Sources/DayOfWeekField.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | class DayOfWeekField: Field, FieldCheckerInterface { 4 | static let currentCalendarWithMondayAsFirstDay: Calendar = { 5 | var calendar = Calendar.current 6 | calendar.firstWeekday = 2 7 | return calendar 8 | }() 9 | 10 | func isSatisfiedBy(_ date: Date, value: String) -> Bool { 11 | let valueToSatisfy = value 12 | 13 | let calendar = DayOfWeekField.currentCalendarWithMondayAsFirstDay 14 | var weekdayWithMondayAsFirstDay = calendar.ordinality(of: .weekday, in: .weekOfYear, for: date)! 15 | 16 | if Int(valueToSatisfy) == 0 { 17 | weekdayWithMondayAsFirstDay = 0 18 | } 19 | 20 | return self.isSatisfied(String(format: "%d", weekdayWithMondayAsFirstDay), value: valueToSatisfy) 21 | } 22 | 23 | func increment(_ date: Date, toMatchValue: String) -> Date { 24 | let calendar = Calendar.current 25 | 26 | // TODO issue 13: handle list items 27 | if let toMatchInt = Int(toMatchValue) { 28 | let converted = Date.convertWeekdayWithMondayFirstToSundayFirst(toMatchInt) 29 | if let nextDate = date.nextDate(matchingUnit: .weekday, value: String(converted)) { 30 | return nextDate 31 | } 32 | } 33 | 34 | let midnightComponents = calendar.dateComponents([.day, .month, .year], from: date) 35 | var components = DateComponents() 36 | components.day = 1 37 | return calendar.date(byAdding: components, to: calendar.date(from: midnightComponents)!)! 38 | } 39 | 40 | func validate(_ value: String) -> Bool { 41 | return StringValidator.isUpperCaseOrNumber(value) 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Sources/Field.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | class Field { 4 | var fields: NSMutableArray? 5 | 6 | func isSatisfied(_ dateValue: String, value: String) -> Bool { 7 | return value == CronRepresentation.DefaultValue || dateValue == value 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Sources/FieldInterface.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FieldCheckerInterface.swift 3 | // SwiftCron 4 | // 5 | // Created by Keegan Rush on 2016/05/05. 6 | // Copyright © 2016 Rush42. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | protocol FieldCheckerInterface { 12 | /** 13 | * Check if the respective value of a DateTime field satisfies a CRON exp 14 | * 15 | * @param DateTime date DateTime object to check 16 | * @param string value CRON expression to test against 17 | * 18 | * @return bool Returns TRUE if satisfied, FALSE otherwise 19 | */ 20 | func isSatisfiedBy(_ date: Date, value: String) -> Bool 21 | 22 | /** 23 | * When a CRON expression is not satisfied, this method is used to increment 24 | * a DateTime object by the unit of the cron field 25 | * 26 | * @param DateTime date DateTime object to increment 27 | * 28 | * @return FieldCheckerInterface 29 | */ 30 | func increment(_ date: Date, toMatchValue: String) -> Date 31 | 32 | /** 33 | * Validates a CRON expression for a given field 34 | * 35 | * @param string value CRON expression value to validate 36 | * 37 | * @return bool Returns TRUE if valid, FALSE otherwise 38 | */ 39 | func validate(_ value: String) -> Bool 40 | } 41 | -------------------------------------------------------------------------------- /Sources/HoursField.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | class HoursField: Field, FieldCheckerInterface { 4 | 5 | func isSatisfiedBy(_ date: Date, value: String) -> Bool { 6 | let calendar = Calendar.current 7 | let components = calendar.dateComponents([.hour], from: date) 8 | guard let hour = components.hour else { return false } 9 | 10 | return isSatisfied(String(format: "%d", hour), value: value) 11 | } 12 | 13 | func increment(_ date: Date, toMatchValue: String) -> Date { 14 | if let nextDate = date.nextDate(matchingUnit: .hour, value: toMatchValue) { 15 | return nextDate 16 | } 17 | 18 | let calendar = Calendar.current 19 | var components = DateComponents() 20 | components.hour = 1 21 | return calendar.date(byAdding: components, to: date)! 22 | } 23 | 24 | func validate(_ value: String) -> Bool { 25 | return StringValidator.isNumber(value) 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Sources/Int+Extensions.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NSNumberFormatter+Extensions.swift 3 | // Pods 4 | // 5 | // Created by Keegan Rush on 2016/05/12. 6 | // 7 | // 8 | 9 | import Foundation 10 | 11 | extension Int: CronFieldTranslatable { 12 | public var cronFieldRepresentation: String { 13 | return String(self) 14 | } 15 | } 16 | 17 | extension Int { 18 | private static let ordinalNumberFormatter: NumberFormatter = { 19 | let formatter = NumberFormatter() 20 | if #available(iOS 9, OSX 10.11, *) { 21 | formatter.numberStyle = .ordinal 22 | } 23 | return formatter 24 | }() 25 | 26 | private static let monthFormatter: DateFormatter = { 27 | let formatter = DateFormatter() 28 | formatter.dateFormat = "MMMM" 29 | return formatter 30 | }() 31 | 32 | var ordinal: String { 33 | return Int.ordinalNumberFormatter.string(from: NSNumber(value: self))! 34 | } 35 | 36 | func convertToMonth() -> String { 37 | assert(self < 13 && self > 0, "Not a valid month") 38 | 39 | let calendar = Calendar.current 40 | var components = DateComponents() 41 | components.month = self 42 | let date = calendar.date(from: components)! 43 | return Int.monthFormatter.string(from: date) 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Sources/MinutesField.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | class MinutesField: Field, FieldCheckerInterface { 4 | 5 | func isSatisfiedBy(_ date: Date, value: String) -> Bool { 6 | let calendar = Calendar.current 7 | let components = calendar.dateComponents([.minute], from: date) 8 | 9 | guard let minute = components.minute else { return false } 10 | 11 | return self.isSatisfied(String(format: "%d", minute), value: value) 12 | } 13 | 14 | func increment(_ date: Date, toMatchValue: String) -> Date { 15 | if let nextDate = date.nextDate(matchingUnit: .minute, value: toMatchValue) { 16 | return nextDate 17 | } 18 | 19 | let calendar = Calendar.current 20 | var components = DateComponents() 21 | components.minute = 1 22 | 23 | return calendar.date(byAdding: components, to: date)! 24 | } 25 | 26 | func validate(_ value: String) -> Bool { 27 | return StringValidator.isNumber(value) 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Sources/MonthField.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | class MonthField: Field, FieldCheckerInterface { 4 | 5 | func isSatisfiedBy(_ date: Date, value: String) -> Bool { 6 | let month = Calendar.current.component(.month, from: date) 7 | return isSatisfied(String(month), value: value) 8 | } 9 | 10 | func increment(_ date: Date, toMatchValue: String) -> Date { 11 | if let nextDate = date.nextDate(matchingUnit: .month, value: toMatchValue) { 12 | return nextDate 13 | } 14 | 15 | let calendar = Calendar.current 16 | let midnightComponents = calendar.dateComponents([.day, .month, .year], from: date) 17 | 18 | var components = DateComponents() 19 | components.month = 1 20 | 21 | return calendar.date(byAdding: components, to: calendar.date(from: midnightComponents)!)! 22 | } 23 | 24 | func validate(_ value: String) -> Bool { 25 | return StringValidator.isUpperCaseOrNumber(value) 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Sources/NSDate+Extensions.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NSDate+Extensions.swift 3 | // Pods 4 | // 5 | // Created by Keegan Rush on 2016/05/25. 6 | // 7 | // 8 | 9 | import Foundation 10 | extension Date { 11 | static func convertWeekdayWithMondayFirstToSundayFirst(_ weekday: Int) -> Int { 12 | let sundayWhenFirstDayOfWeek = 1 13 | let sundayWhenMondayFirst = 7 14 | 15 | // Currently arranged from 1-7 starting at Sunday. Rearrange to 1-7 starting at Monday. 16 | if weekday == sundayWhenMondayFirst { 17 | return sundayWhenFirstDayOfWeek 18 | } 19 | return weekday + 1 20 | } 21 | 22 | func nextDate(matchingUnit unit: NSCalendar.Unit, value: String) -> Date? { 23 | let calendar = Calendar.current 24 | 25 | var valueToMatch: Int! 26 | 27 | if value.contains(CronRepresentation.ListIdentifier) { 28 | // TODO: issue 13: Match list items 29 | return nil 30 | } else { 31 | valueToMatch = Int(value) 32 | } 33 | 34 | guard valueToMatch != nil else { 35 | return nil 36 | } 37 | 38 | var components = DateComponents() 39 | 40 | switch unit { 41 | case NSCalendar.Unit.era: 42 | components.era = valueToMatch 43 | case NSCalendar.Unit.year: 44 | if calendar.component(.year, from: self) >= valueToMatch { 45 | return nil 46 | } 47 | components.year = valueToMatch 48 | case NSCalendar.Unit.month: 49 | components.month = valueToMatch 50 | case NSCalendar.Unit.day: 51 | components.day = valueToMatch 52 | case NSCalendar.Unit.hour: 53 | components.hour = valueToMatch 54 | case NSCalendar.Unit.minute: 55 | components.minute = valueToMatch 56 | case NSCalendar.Unit.second: 57 | components.second = valueToMatch 58 | case NSCalendar.Unit.weekday: 59 | components.weekday = valueToMatch 60 | case NSCalendar.Unit.weekdayOrdinal: 61 | components.weekdayOrdinal = valueToMatch 62 | case NSCalendar.Unit.quarter: 63 | components.quarter = valueToMatch 64 | case NSCalendar.Unit.weekOfMonth: 65 | components.weekOfMonth = valueToMatch 66 | case NSCalendar.Unit.weekOfYear: 67 | components.weekOfYear = valueToMatch 68 | case NSCalendar.Unit.yearForWeekOfYear: 69 | components.yearForWeekOfYear = valueToMatch 70 | case NSCalendar.Unit.nanosecond: 71 | components.nanosecond = valueToMatch 72 | default: 73 | print("\(#function): Not a valid calendar unit for this function.") 74 | return nil 75 | } 76 | 77 | return calendar.nextDate(after: self, matching: components, matchingPolicy: .strict) 78 | } 79 | 80 | func getLastDayOfMonth() -> Int { 81 | let calendar = Calendar.current 82 | let components = calendar.dateComponents([.month], from: self) 83 | 84 | switch components.month! { 85 | case 1, 3, 5, 7, 8, 10, 12: 86 | return 31 87 | case 2: 88 | let range = calendar.range(of: .day, in: .month, for: calendar.date(from: components)!)! 89 | return range.upperBound - range.lowerBound 90 | default: 91 | return 30 92 | } 93 | } 94 | 95 | } 96 | -------------------------------------------------------------------------------- /Sources/NSDateFormatter+Extensions.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NSDateFormatter+Extensions.swift 3 | // Pods 4 | // 5 | // Created by Keegan Rush on 2016/05/12. 6 | // 7 | // 8 | 9 | import Foundation 10 | 11 | extension DateFormatter { 12 | private static let timeDateFormatter: DateFormatter = { 13 | let dateFormatter = DateFormatter() 14 | dateFormatter.dateFormat = "HH:mm" 15 | return dateFormatter 16 | }() 17 | 18 | private static let minuteDateFormatter: DateFormatter = { 19 | let dateFormatter = DateFormatter() 20 | dateFormatter.dateFormat = "mm" 21 | return dateFormatter 22 | }() 23 | 24 | private static let weekdayFormatter: DateFormatter = { 25 | let formatter = DateFormatter() 26 | formatter.dateFormat = "EEEE" 27 | return formatter 28 | }() 29 | 30 | static func timeStringWithHour(_ hour: String, minute: String) -> String { 31 | let theHour = Int(hour) 32 | let theMinute = Int(minute) 33 | // assert(theMinute < 60 && theMinute > -1) 34 | // assert(theHour > -1 && theHour < 25) 35 | 36 | let calendar = Calendar.current 37 | var components = DateComponents() 38 | components.hour = theHour 39 | components.minute = theMinute 40 | let date = calendar.date(from: components)! 41 | return timeDateFormatter.string(from: date) 42 | } 43 | 44 | static func minuteStringWithMinute(_ minute: String) -> String { 45 | let theMinute = Int(minute)! 46 | assert(theMinute < 60 && theMinute > -1) 47 | 48 | let calendar = Calendar.current 49 | var components = DateComponents() 50 | components.minute = theMinute 51 | let date = calendar.date(from: components)! 52 | return minuteDateFormatter.string(from: date) 53 | } 54 | 55 | static func convertStringToDaysOfWeek(_ weekdaysString: String) -> String { 56 | 57 | var daysOfWeekArray: Array = [] 58 | let days = weekdaysString.components(separatedBy: CronRepresentation.ListIdentifier) 59 | 60 | let calendar = Calendar.current 61 | let searchDate = Date(timeIntervalSince1970: 0) 62 | var components = DateComponents() 63 | 64 | for day in days { 65 | // Currently arranged from 1-7 starting at Sunday. Rearrange to 1-7 starting at Monday. 66 | let dayNumber = Date.convertWeekdayWithMondayFirstToSundayFirst(Int(day)!) 67 | 68 | assert(dayNumber >= 1 && dayNumber <= 7, "Day does not fit in week") 69 | components.weekday = dayNumber 70 | let date = calendar.nextDate(after: searchDate, matching: components, matchingPolicy: .strict)! 71 | let dayString = DateFormatter.weekdayFormatter.string(from: date) 72 | if days.contains(dayString) == false { 73 | daysOfWeekArray.append(dayString) 74 | } 75 | } 76 | 77 | // Sunday will be first. Make it last 78 | let sunday = "Sunday" 79 | if daysOfWeekArray.contains(sunday) { 80 | daysOfWeekArray.remove(at: daysOfWeekArray.firstIndex(of: sunday)!) 81 | daysOfWeekArray.append(sunday) 82 | } 83 | 84 | return daysOfWeekArray.joined(separator: ", ") 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /Sources/String+Extensions.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Keegan Rush on 2016/06/11. 3 | // 4 | 5 | import Foundation 6 | 7 | extension String: CronFieldTranslatable { 8 | public var cronFieldRepresentation: String { 9 | return self 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Sources/StringValidator.swift: -------------------------------------------------------------------------------- 1 | // 2 | // StringValidator.swift 3 | // Pods 4 | // 5 | // Created by Keegan Rush on 2016/12/22. 6 | // 7 | // 8 | 9 | import Foundation 10 | 11 | struct StringValidator { 12 | 13 | static func isUpperCaseOrNumber(_ value: String) -> Bool { 14 | return validate(value, regex: "[\\*,\\/\\-0-9A-Z]+") 15 | } 16 | 17 | static func isNumber(_ value: String) -> Bool { 18 | return validate(value, regex: "[\\*,\\/\\-0-9]+") 19 | } 20 | 21 | static func isAlphanumeric(_ value: String) -> Bool { 22 | return validate(value, regex: "[\\*,\\/\\-\\?LW0-9A-Za-z]+") 23 | } 24 | 25 | private static func validate(_ value: String, regex: String) -> Bool { 26 | #if os(Linux) 27 | typealias Regex = RegularExpression 28 | #else 29 | typealias Regex = NSRegularExpression 30 | #endif 31 | 32 | guard let regex = try? Regex(pattern: regex, options: []) else { return false } 33 | return regex.numberOfMatches(in: value, options: [], range: NSMakeRange(0, value.count)) > 0 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Sources/YearField.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | class YearField: Field, FieldCheckerInterface { 4 | 5 | func isSatisfiedBy(_ date: Date, value: String) -> Bool { 6 | let calendar = Calendar.current 7 | let components = calendar.dateComponents([.year], from: date) 8 | 9 | guard let year = components.year else { return false } 10 | 11 | return self.isSatisfied(String(format: "%d", year), value: value) 12 | } 13 | 14 | func increment(_ date: Date, toMatchValue: String) -> Date { 15 | if let nextDate = date.nextDate(matchingUnit: .year, value: toMatchValue) { 16 | return nextDate 17 | } 18 | 19 | let calendar = Calendar.current 20 | let midnightComponents = calendar.dateComponents([.day, .month, .year], from: date) 21 | 22 | var components = DateComponents() 23 | components.year = 1 24 | 25 | return calendar.date(byAdding: components, to: calendar.date(from: midnightComponents)!)! 26 | } 27 | 28 | func validate(_ value: String) -> Bool { 29 | return StringValidator.isNumber(value) 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /SwiftCron.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "SwiftCron" 3 | s.version = "0.5.0" 4 | s.summary = "Cron expression parser." 5 | 6 | 7 | s.description = <<-DESC 8 | A cron expression parser written in Swift that can take a cron string and give you the next run date and time specified in the string. 9 | DESC 10 | 11 | s.homepage = "https://github.com/TheCodedSelf/SwiftCron" 12 | s.license = 'MIT' 13 | s.author = { "Keegan Rush" => "thecodedself@gmail.com" } 14 | s.source = { :git => "https://github.com/TheCodedSelf/SwiftCron.git", :tag => "#{s.version}" } 15 | s.social_media_url = 'https://twitter.com/RushKeegan' 16 | 17 | s.ios.deployment_target = '9.0' 18 | 19 | s.source_files = 'Sources/**/*' 20 | end 21 | -------------------------------------------------------------------------------- /SwiftCron.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 9577E8FC1E7396D4007854EE /* SwiftCron.h in Headers */ = {isa = PBXBuildFile; fileRef = 9577E8FA1E7396D4007854EE /* SwiftCron.h */; settings = {ATTRIBUTES = (Public, ); }; }; 11 | 959BFF701E739CFA00A788E2 /* CronDescriptionBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 959BFF5F1E739CFA00A788E2 /* CronDescriptionBuilder.swift */; }; 12 | 959BFF711E739CFA00A788E2 /* CronExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = 959BFF601E739CFA00A788E2 /* CronExpression.swift */; }; 13 | 959BFF721E739CFA00A788E2 /* CronFieldTranslatable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 959BFF611E739CFA00A788E2 /* CronFieldTranslatable.swift */; }; 14 | 959BFF731E739CFA00A788E2 /* CronRepresentation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 959BFF621E739CFA00A788E2 /* CronRepresentation.swift */; }; 15 | 959BFF741E739CFA00A788E2 /* DayOfMonthField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 959BFF631E739CFA00A788E2 /* DayOfMonthField.swift */; }; 16 | 959BFF751E739CFA00A788E2 /* DayOfWeekField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 959BFF641E739CFA00A788E2 /* DayOfWeekField.swift */; }; 17 | 959BFF761E739CFA00A788E2 /* Field.swift in Sources */ = {isa = PBXBuildFile; fileRef = 959BFF651E739CFA00A788E2 /* Field.swift */; }; 18 | 959BFF771E739CFA00A788E2 /* FieldInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 959BFF661E739CFA00A788E2 /* FieldInterface.swift */; }; 19 | 959BFF781E739CFA00A788E2 /* HoursField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 959BFF671E739CFA00A788E2 /* HoursField.swift */; }; 20 | 959BFF791E739CFA00A788E2 /* Int+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 959BFF681E739CFA00A788E2 /* Int+Extensions.swift */; }; 21 | 959BFF7A1E739CFA00A788E2 /* MinutesField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 959BFF691E739CFA00A788E2 /* MinutesField.swift */; }; 22 | 959BFF7B1E739CFA00A788E2 /* MonthField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 959BFF6A1E739CFA00A788E2 /* MonthField.swift */; }; 23 | 959BFF7C1E739CFA00A788E2 /* NSDate+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 959BFF6B1E739CFA00A788E2 /* NSDate+Extensions.swift */; }; 24 | 959BFF7D1E739CFA00A788E2 /* NSDateFormatter+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 959BFF6C1E739CFA00A788E2 /* NSDateFormatter+Extensions.swift */; }; 25 | 959BFF7E1E739CFA00A788E2 /* String+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 959BFF6D1E739CFA00A788E2 /* String+Extensions.swift */; }; 26 | 959BFF7F1E739CFA00A788E2 /* StringValidator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 959BFF6E1E739CFA00A788E2 /* StringValidator.swift */; }; 27 | 959BFF801E739CFA00A788E2 /* YearField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 959BFF6F1E739CFA00A788E2 /* YearField.swift */; }; 28 | /* End PBXBuildFile section */ 29 | 30 | /* Begin PBXFileReference section */ 31 | 9577E8F71E7396D4007854EE /* SwiftCron.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SwiftCron.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 32 | 9577E8FA1E7396D4007854EE /* SwiftCron.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SwiftCron.h; sourceTree = ""; }; 33 | 9577E8FB1E7396D4007854EE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 34 | 959BFF5F1E739CFA00A788E2 /* CronDescriptionBuilder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = CronDescriptionBuilder.swift; path = Sources/CronDescriptionBuilder.swift; sourceTree = SOURCE_ROOT; }; 35 | 959BFF601E739CFA00A788E2 /* CronExpression.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = CronExpression.swift; path = Sources/CronExpression.swift; sourceTree = SOURCE_ROOT; }; 36 | 959BFF611E739CFA00A788E2 /* CronFieldTranslatable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = CronFieldTranslatable.swift; path = Sources/CronFieldTranslatable.swift; sourceTree = SOURCE_ROOT; }; 37 | 959BFF621E739CFA00A788E2 /* CronRepresentation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = CronRepresentation.swift; path = Sources/CronRepresentation.swift; sourceTree = SOURCE_ROOT; }; 38 | 959BFF631E739CFA00A788E2 /* DayOfMonthField.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = DayOfMonthField.swift; path = Sources/DayOfMonthField.swift; sourceTree = SOURCE_ROOT; }; 39 | 959BFF641E739CFA00A788E2 /* DayOfWeekField.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = DayOfWeekField.swift; path = Sources/DayOfWeekField.swift; sourceTree = SOURCE_ROOT; }; 40 | 959BFF651E739CFA00A788E2 /* Field.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Field.swift; path = Sources/Field.swift; sourceTree = SOURCE_ROOT; }; 41 | 959BFF661E739CFA00A788E2 /* FieldInterface.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = FieldInterface.swift; path = Sources/FieldInterface.swift; sourceTree = SOURCE_ROOT; }; 42 | 959BFF671E739CFA00A788E2 /* HoursField.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = HoursField.swift; path = Sources/HoursField.swift; sourceTree = SOURCE_ROOT; }; 43 | 959BFF681E739CFA00A788E2 /* Int+Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "Int+Extensions.swift"; path = "Sources/Int+Extensions.swift"; sourceTree = SOURCE_ROOT; }; 44 | 959BFF691E739CFA00A788E2 /* MinutesField.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = MinutesField.swift; path = Sources/MinutesField.swift; sourceTree = SOURCE_ROOT; }; 45 | 959BFF6A1E739CFA00A788E2 /* MonthField.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = MonthField.swift; path = Sources/MonthField.swift; sourceTree = SOURCE_ROOT; }; 46 | 959BFF6B1E739CFA00A788E2 /* NSDate+Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "NSDate+Extensions.swift"; path = "Sources/NSDate+Extensions.swift"; sourceTree = SOURCE_ROOT; }; 47 | 959BFF6C1E739CFA00A788E2 /* NSDateFormatter+Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "NSDateFormatter+Extensions.swift"; path = "Sources/NSDateFormatter+Extensions.swift"; sourceTree = SOURCE_ROOT; }; 48 | 959BFF6D1E739CFA00A788E2 /* String+Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "String+Extensions.swift"; path = "Sources/String+Extensions.swift"; sourceTree = SOURCE_ROOT; }; 49 | 959BFF6E1E739CFA00A788E2 /* StringValidator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = StringValidator.swift; path = Sources/StringValidator.swift; sourceTree = SOURCE_ROOT; }; 50 | 959BFF6F1E739CFA00A788E2 /* YearField.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = YearField.swift; path = Sources/YearField.swift; sourceTree = SOURCE_ROOT; }; 51 | /* End PBXFileReference section */ 52 | 53 | /* Begin PBXFrameworksBuildPhase section */ 54 | 9577E8F31E7396D4007854EE /* Frameworks */ = { 55 | isa = PBXFrameworksBuildPhase; 56 | buildActionMask = 2147483647; 57 | files = ( 58 | ); 59 | runOnlyForDeploymentPostprocessing = 0; 60 | }; 61 | /* End PBXFrameworksBuildPhase section */ 62 | 63 | /* Begin PBXGroup section */ 64 | 9577E8ED1E7396D4007854EE = { 65 | isa = PBXGroup; 66 | children = ( 67 | 9577E8F91E7396D4007854EE /* SwiftCron */, 68 | 9577E8F81E7396D4007854EE /* Products */, 69 | ); 70 | sourceTree = ""; 71 | }; 72 | 9577E8F81E7396D4007854EE /* Products */ = { 73 | isa = PBXGroup; 74 | children = ( 75 | 9577E8F71E7396D4007854EE /* SwiftCron.framework */, 76 | ); 77 | name = Products; 78 | sourceTree = ""; 79 | }; 80 | 9577E8F91E7396D4007854EE /* SwiftCron */ = { 81 | isa = PBXGroup; 82 | children = ( 83 | 9577E9021E7396E1007854EE /* Sources */, 84 | 9577E8FA1E7396D4007854EE /* SwiftCron.h */, 85 | 9577E8FB1E7396D4007854EE /* Info.plist */, 86 | ); 87 | path = SwiftCron; 88 | sourceTree = ""; 89 | }; 90 | 9577E9021E7396E1007854EE /* Sources */ = { 91 | isa = PBXGroup; 92 | children = ( 93 | 959BFF5F1E739CFA00A788E2 /* CronDescriptionBuilder.swift */, 94 | 959BFF601E739CFA00A788E2 /* CronExpression.swift */, 95 | 959BFF611E739CFA00A788E2 /* CronFieldTranslatable.swift */, 96 | 959BFF621E739CFA00A788E2 /* CronRepresentation.swift */, 97 | 959BFF631E739CFA00A788E2 /* DayOfMonthField.swift */, 98 | 959BFF641E739CFA00A788E2 /* DayOfWeekField.swift */, 99 | 959BFF651E739CFA00A788E2 /* Field.swift */, 100 | 959BFF661E739CFA00A788E2 /* FieldInterface.swift */, 101 | 959BFF671E739CFA00A788E2 /* HoursField.swift */, 102 | 959BFF681E739CFA00A788E2 /* Int+Extensions.swift */, 103 | 959BFF691E739CFA00A788E2 /* MinutesField.swift */, 104 | 959BFF6A1E739CFA00A788E2 /* MonthField.swift */, 105 | 959BFF6B1E739CFA00A788E2 /* NSDate+Extensions.swift */, 106 | 959BFF6C1E739CFA00A788E2 /* NSDateFormatter+Extensions.swift */, 107 | 959BFF6D1E739CFA00A788E2 /* String+Extensions.swift */, 108 | 959BFF6E1E739CFA00A788E2 /* StringValidator.swift */, 109 | 959BFF6F1E739CFA00A788E2 /* YearField.swift */, 110 | ); 111 | name = Sources; 112 | path = ../../Sources; 113 | sourceTree = ""; 114 | }; 115 | /* End PBXGroup section */ 116 | 117 | /* Begin PBXHeadersBuildPhase section */ 118 | 9577E8F41E7396D4007854EE /* Headers */ = { 119 | isa = PBXHeadersBuildPhase; 120 | buildActionMask = 2147483647; 121 | files = ( 122 | 9577E8FC1E7396D4007854EE /* SwiftCron.h in Headers */, 123 | ); 124 | runOnlyForDeploymentPostprocessing = 0; 125 | }; 126 | /* End PBXHeadersBuildPhase section */ 127 | 128 | /* Begin PBXNativeTarget section */ 129 | 9577E8F61E7396D4007854EE /* SwiftCron */ = { 130 | isa = PBXNativeTarget; 131 | buildConfigurationList = 9577E8FF1E7396D4007854EE /* Build configuration list for PBXNativeTarget "SwiftCron" */; 132 | buildPhases = ( 133 | 9577E8F21E7396D4007854EE /* Sources */, 134 | 9577E8F31E7396D4007854EE /* Frameworks */, 135 | 9577E8F41E7396D4007854EE /* Headers */, 136 | 9577E8F51E7396D4007854EE /* Resources */, 137 | ); 138 | buildRules = ( 139 | ); 140 | dependencies = ( 141 | ); 142 | name = SwiftCron; 143 | productName = SwiftCron; 144 | productReference = 9577E8F71E7396D4007854EE /* SwiftCron.framework */; 145 | productType = "com.apple.product-type.framework"; 146 | }; 147 | /* End PBXNativeTarget section */ 148 | 149 | /* Begin PBXProject section */ 150 | 9577E8EE1E7396D4007854EE /* Project object */ = { 151 | isa = PBXProject; 152 | attributes = { 153 | LastUpgradeCheck = 1000; 154 | ORGANIZATIONNAME = TheCodedSelf; 155 | TargetAttributes = { 156 | 9577E8F61E7396D4007854EE = { 157 | CreatedOnToolsVersion = 8.2.1; 158 | LastSwiftMigration = 1100; 159 | ProvisioningStyle = Automatic; 160 | }; 161 | }; 162 | }; 163 | buildConfigurationList = 9577E8F11E7396D4007854EE /* Build configuration list for PBXProject "SwiftCron" */; 164 | compatibilityVersion = "Xcode 3.2"; 165 | developmentRegion = en; 166 | hasScannedForEncodings = 0; 167 | knownRegions = ( 168 | en, 169 | Base, 170 | ); 171 | mainGroup = 9577E8ED1E7396D4007854EE; 172 | productRefGroup = 9577E8F81E7396D4007854EE /* Products */; 173 | projectDirPath = ""; 174 | projectRoot = ""; 175 | targets = ( 176 | 9577E8F61E7396D4007854EE /* SwiftCron */, 177 | ); 178 | }; 179 | /* End PBXProject section */ 180 | 181 | /* Begin PBXResourcesBuildPhase section */ 182 | 9577E8F51E7396D4007854EE /* Resources */ = { 183 | isa = PBXResourcesBuildPhase; 184 | buildActionMask = 2147483647; 185 | files = ( 186 | ); 187 | runOnlyForDeploymentPostprocessing = 0; 188 | }; 189 | /* End PBXResourcesBuildPhase section */ 190 | 191 | /* Begin PBXSourcesBuildPhase section */ 192 | 9577E8F21E7396D4007854EE /* Sources */ = { 193 | isa = PBXSourcesBuildPhase; 194 | buildActionMask = 2147483647; 195 | files = ( 196 | 959BFF7D1E739CFA00A788E2 /* NSDateFormatter+Extensions.swift in Sources */, 197 | 959BFF751E739CFA00A788E2 /* DayOfWeekField.swift in Sources */, 198 | 959BFF7B1E739CFA00A788E2 /* MonthField.swift in Sources */, 199 | 959BFF801E739CFA00A788E2 /* YearField.swift in Sources */, 200 | 959BFF741E739CFA00A788E2 /* DayOfMonthField.swift in Sources */, 201 | 959BFF731E739CFA00A788E2 /* CronRepresentation.swift in Sources */, 202 | 959BFF721E739CFA00A788E2 /* CronFieldTranslatable.swift in Sources */, 203 | 959BFF771E739CFA00A788E2 /* FieldInterface.swift in Sources */, 204 | 959BFF701E739CFA00A788E2 /* CronDescriptionBuilder.swift in Sources */, 205 | 959BFF761E739CFA00A788E2 /* Field.swift in Sources */, 206 | 959BFF7A1E739CFA00A788E2 /* MinutesField.swift in Sources */, 207 | 959BFF7E1E739CFA00A788E2 /* String+Extensions.swift in Sources */, 208 | 959BFF711E739CFA00A788E2 /* CronExpression.swift in Sources */, 209 | 959BFF7C1E739CFA00A788E2 /* NSDate+Extensions.swift in Sources */, 210 | 959BFF7F1E739CFA00A788E2 /* StringValidator.swift in Sources */, 211 | 959BFF781E739CFA00A788E2 /* HoursField.swift in Sources */, 212 | 959BFF791E739CFA00A788E2 /* Int+Extensions.swift in Sources */, 213 | ); 214 | runOnlyForDeploymentPostprocessing = 0; 215 | }; 216 | /* End PBXSourcesBuildPhase section */ 217 | 218 | /* Begin XCBuildConfiguration section */ 219 | 9577E8FD1E7396D4007854EE /* Debug */ = { 220 | isa = XCBuildConfiguration; 221 | buildSettings = { 222 | ALWAYS_SEARCH_USER_PATHS = NO; 223 | CLANG_ANALYZER_NONNULL = YES; 224 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 225 | CLANG_CXX_LIBRARY = "libc++"; 226 | CLANG_ENABLE_MODULES = YES; 227 | CLANG_ENABLE_OBJC_ARC = YES; 228 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 229 | CLANG_WARN_BOOL_CONVERSION = YES; 230 | CLANG_WARN_COMMA = YES; 231 | CLANG_WARN_CONSTANT_CONVERSION = YES; 232 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 233 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 234 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 235 | CLANG_WARN_EMPTY_BODY = YES; 236 | CLANG_WARN_ENUM_CONVERSION = YES; 237 | CLANG_WARN_INFINITE_RECURSION = YES; 238 | CLANG_WARN_INT_CONVERSION = YES; 239 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 240 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 241 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 242 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 243 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 244 | CLANG_WARN_STRICT_PROTOTYPES = YES; 245 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 246 | CLANG_WARN_UNREACHABLE_CODE = YES; 247 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 248 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 249 | COPY_PHASE_STRIP = NO; 250 | CURRENT_PROJECT_VERSION = 1; 251 | DEBUG_INFORMATION_FORMAT = dwarf; 252 | ENABLE_STRICT_OBJC_MSGSEND = YES; 253 | ENABLE_TESTABILITY = YES; 254 | GCC_C_LANGUAGE_STANDARD = gnu99; 255 | GCC_DYNAMIC_NO_PIC = NO; 256 | GCC_NO_COMMON_BLOCKS = YES; 257 | GCC_OPTIMIZATION_LEVEL = 0; 258 | GCC_PREPROCESSOR_DEFINITIONS = ( 259 | "DEBUG=1", 260 | "$(inherited)", 261 | ); 262 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 263 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 264 | GCC_WARN_UNDECLARED_SELECTOR = YES; 265 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 266 | GCC_WARN_UNUSED_FUNCTION = YES; 267 | GCC_WARN_UNUSED_VARIABLE = YES; 268 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 269 | MTL_ENABLE_DEBUG_INFO = YES; 270 | ONLY_ACTIVE_ARCH = YES; 271 | SDKROOT = iphoneos; 272 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 273 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 274 | SWIFT_SWIFT3_OBJC_INFERENCE = Off; 275 | SWIFT_VERSION = 5.0; 276 | TARGETED_DEVICE_FAMILY = "1,2"; 277 | VERSIONING_SYSTEM = "apple-generic"; 278 | VERSION_INFO_PREFIX = ""; 279 | }; 280 | name = Debug; 281 | }; 282 | 9577E8FE1E7396D4007854EE /* Release */ = { 283 | isa = XCBuildConfiguration; 284 | buildSettings = { 285 | ALWAYS_SEARCH_USER_PATHS = NO; 286 | CLANG_ANALYZER_NONNULL = YES; 287 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 288 | CLANG_CXX_LIBRARY = "libc++"; 289 | CLANG_ENABLE_MODULES = YES; 290 | CLANG_ENABLE_OBJC_ARC = YES; 291 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 292 | CLANG_WARN_BOOL_CONVERSION = YES; 293 | CLANG_WARN_COMMA = YES; 294 | CLANG_WARN_CONSTANT_CONVERSION = YES; 295 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 296 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 297 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 298 | CLANG_WARN_EMPTY_BODY = YES; 299 | CLANG_WARN_ENUM_CONVERSION = YES; 300 | CLANG_WARN_INFINITE_RECURSION = YES; 301 | CLANG_WARN_INT_CONVERSION = YES; 302 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 303 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 304 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 305 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 306 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 307 | CLANG_WARN_STRICT_PROTOTYPES = YES; 308 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 309 | CLANG_WARN_UNREACHABLE_CODE = YES; 310 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 311 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 312 | COPY_PHASE_STRIP = NO; 313 | CURRENT_PROJECT_VERSION = 1; 314 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 315 | ENABLE_NS_ASSERTIONS = NO; 316 | ENABLE_STRICT_OBJC_MSGSEND = YES; 317 | GCC_C_LANGUAGE_STANDARD = gnu99; 318 | GCC_NO_COMMON_BLOCKS = YES; 319 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 320 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 321 | GCC_WARN_UNDECLARED_SELECTOR = YES; 322 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 323 | GCC_WARN_UNUSED_FUNCTION = YES; 324 | GCC_WARN_UNUSED_VARIABLE = YES; 325 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 326 | MTL_ENABLE_DEBUG_INFO = NO; 327 | SDKROOT = iphoneos; 328 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 329 | SWIFT_SWIFT3_OBJC_INFERENCE = Off; 330 | SWIFT_VERSION = 5.0; 331 | TARGETED_DEVICE_FAMILY = "1,2"; 332 | VALIDATE_PRODUCT = YES; 333 | VERSIONING_SYSTEM = "apple-generic"; 334 | VERSION_INFO_PREFIX = ""; 335 | }; 336 | name = Release; 337 | }; 338 | 9577E9001E7396D4007854EE /* Debug */ = { 339 | isa = XCBuildConfiguration; 340 | buildSettings = { 341 | CLANG_ENABLE_MODULES = YES; 342 | CODE_SIGN_IDENTITY = ""; 343 | DEFINES_MODULE = YES; 344 | DYLIB_COMPATIBILITY_VERSION = 1; 345 | DYLIB_CURRENT_VERSION = 1; 346 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 347 | INFOPLIST_FILE = SwiftCron/Info.plist; 348 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 349 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 350 | PRODUCT_BUNDLE_IDENTIFIER = com.thecodedself.SwiftCron; 351 | PRODUCT_NAME = "$(TARGET_NAME)"; 352 | SKIP_INSTALL = YES; 353 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 354 | SWIFT_SWIFT3_OBJC_INFERENCE = Off; 355 | SWIFT_VERSION = 5.0; 356 | }; 357 | name = Debug; 358 | }; 359 | 9577E9011E7396D4007854EE /* Release */ = { 360 | isa = XCBuildConfiguration; 361 | buildSettings = { 362 | CLANG_ENABLE_MODULES = YES; 363 | CODE_SIGN_IDENTITY = ""; 364 | DEFINES_MODULE = YES; 365 | DYLIB_COMPATIBILITY_VERSION = 1; 366 | DYLIB_CURRENT_VERSION = 1; 367 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 368 | INFOPLIST_FILE = SwiftCron/Info.plist; 369 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 370 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 371 | PRODUCT_BUNDLE_IDENTIFIER = com.thecodedself.SwiftCron; 372 | PRODUCT_NAME = "$(TARGET_NAME)"; 373 | SKIP_INSTALL = YES; 374 | SWIFT_SWIFT3_OBJC_INFERENCE = Off; 375 | SWIFT_VERSION = 5.0; 376 | }; 377 | name = Release; 378 | }; 379 | /* End XCBuildConfiguration section */ 380 | 381 | /* Begin XCConfigurationList section */ 382 | 9577E8F11E7396D4007854EE /* Build configuration list for PBXProject "SwiftCron" */ = { 383 | isa = XCConfigurationList; 384 | buildConfigurations = ( 385 | 9577E8FD1E7396D4007854EE /* Debug */, 386 | 9577E8FE1E7396D4007854EE /* Release */, 387 | ); 388 | defaultConfigurationIsVisible = 0; 389 | defaultConfigurationName = Release; 390 | }; 391 | 9577E8FF1E7396D4007854EE /* Build configuration list for PBXNativeTarget "SwiftCron" */ = { 392 | isa = XCConfigurationList; 393 | buildConfigurations = ( 394 | 9577E9001E7396D4007854EE /* Debug */, 395 | 9577E9011E7396D4007854EE /* Release */, 396 | ); 397 | defaultConfigurationIsVisible = 0; 398 | defaultConfigurationName = Release; 399 | }; 400 | /* End XCConfigurationList section */ 401 | }; 402 | rootObject = 9577E8EE1E7396D4007854EE /* Project object */; 403 | } 404 | -------------------------------------------------------------------------------- /SwiftCron.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /SwiftCron.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /SwiftCron.xcodeproj/xcshareddata/xcschemes/SwiftCron.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 45 | 46 | 52 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 70 | 71 | 72 | 73 | 75 | 76 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /SwiftCron/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | $(CURRENT_PROJECT_VERSION) 21 | NSPrincipalClass 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /SwiftCron/SwiftCron.h: -------------------------------------------------------------------------------- 1 | // 2 | // SwiftCron.h 3 | // SwiftCron 4 | // 5 | // Created by Keegan Rush on 2017/03/11. 6 | // Copyright © 2017 TheCodedSelf. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for SwiftCron. 12 | FOUNDATION_EXPORT double SwiftCronVersionNumber; 13 | 14 | //! Project version string for SwiftCron. 15 | FOUNDATION_EXPORT const unsigned char SwiftCronVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | 19 | 20 | --------------------------------------------------------------------------------