# HG changeset patch # User Dennis C. M. # Date 1666765219 -7200 # Node ID 56add556126128e46d197603fae4f146571ee8b4 # Parent b145c408f7913252c37ef2387f8f2c33a0e98bb2 add mock data creation diff -r b145c408f791 -r 56add5561261 GeoQuiz/Components/RecentGame.swift --- a/GeoQuiz/Components/RecentGame.swift Tue Oct 25 15:30:01 2022 +0200 +++ b/GeoQuiz/Components/RecentGame.swift Wed Oct 26 08:20:19 2022 +0200 @@ -37,7 +37,7 @@ Text(gameInfo.name) .font(.headline) - Text("\(game.date ?? Date(), format: .dateTime)") + Text("\(game.date ?? Date(), format: .dateTime.day().month().year())") .font(.callout) .foregroundColor(.secondary) } diff -r b145c408f791 -r 56add5561261 GeoQuiz/Logic/PersistenceController.swift --- a/GeoQuiz/Logic/PersistenceController.swift Tue Oct 25 15:30:01 2022 +0200 +++ b/GeoQuiz/Logic/PersistenceController.swift Wed Oct 26 08:20:19 2022 +0200 @@ -16,7 +16,10 @@ static var preview: PersistenceController = { let result = PersistenceController(inMemory: true) let viewContext = result.container.viewContext + + #if DEBUG createMockData(nil, viewContext) + #endif return result }() @@ -44,7 +47,9 @@ playedGame.type = GameType(rawValue: Int16.random(in: 0...3))! playedGame.score = Int32.random(in: 0...50) - playedGame.date = Date() + + let dayComponent = DateComponents(day: Int.random(in: -5...0)) + playedGame.date = Calendar.current.date(byAdding: dayComponent, to: Date()) if playedGame.type == .guessTheFlag || playedGame.type == .guessTheCapital { playedGame.correctAnswers = ["Bangladesh", "Belgium", "Burkina Faso", "Bermuda", "Jamaica"] diff -r b145c408f791 -r 56add5561261 GeoQuiz/ProfileModalView.swift --- a/GeoQuiz/ProfileModalView.swift Tue Oct 25 15:30:01 2022 +0200 +++ b/GeoQuiz/ProfileModalView.swift Wed Oct 26 08:20:19 2022 +0200 @@ -80,7 +80,7 @@ #if DEBUG .onAppear { - + PersistenceController.createMockData(playedGames, moc) } #endif }