Skip to content

Commit 3ed1ef4

Browse files
committed
Use Calendar compare
1 parent d4cf730 commit 3ed1ef4

File tree

8 files changed

+13
-18
lines changed

8 files changed

+13
-18
lines changed

Sources/GateEngine/Resources/CollisionMesh/CollisionMesh.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ extension ResourceManager {
329329
do {
330330
let attributes = try FileManager.default.attributesOfItem(atPath: path)
331331
if let modified = (attributes[.modificationDate] ?? attributes[.creationDate]) as? Date {
332-
return modified > cache.lastLoaded
332+
return Calendar.current.compare(modified, to: cache.lastLoaded, toGranularity: .second) == .orderedDescending
333333
} else {
334334
return false
335335
}

Sources/GateEngine/Resources/Geometry/Geometry.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ extension ResourceManager {
359359
do {
360360
let attributes = try FileManager.default.attributesOfItem(atPath: path)
361361
if let modified = (attributes[.modificationDate] ?? attributes[.creationDate]) as? Date {
362-
return modified > cache.lastLoaded
362+
return Calendar.current.compare(modified, to: cache.lastLoaded, toGranularity: .second) == .orderedDescending
363363
} else {
364364
return false
365365
}

Sources/GateEngine/Resources/Geometry/SkinnedGeometry.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,8 @@ extension ResourceManager {
253253
guard let path = Platform.current.synchronousLocateResource(from: key.requestedPath) else {return false}
254254
do {
255255
let attributes = try FileManager.default.attributesOfItem(atPath: path)
256-
if let modified = (attributes[.modificationDate] ?? attributes[.creationDate]) as? Date
257-
{
258-
return modified > cache.lastLoaded
256+
if let modified = (attributes[.modificationDate] ?? attributes[.creationDate]) as? Date {
257+
return Calendar.current.compare(modified, to: cache.lastLoaded, toGranularity: .second) == .orderedDescending
259258
} else {
260259
return false
261260
}

Sources/GateEngine/Resources/Skinning/SkeletalAnimation.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -500,9 +500,8 @@ extension ResourceManager {
500500
guard let path = Platform.current.synchronousLocateResource(from: key.requestedPath) else {return false}
501501
do {
502502
let attributes = try FileManager.default.attributesOfItem(atPath: path)
503-
if let modified = (attributes[.modificationDate] ?? attributes[.creationDate]) as? Date
504-
{
505-
return modified > cache.lastLoaded
503+
if let modified = (attributes[.modificationDate] ?? attributes[.creationDate]) as? Date {
504+
return Calendar.current.compare(modified, to: cache.lastLoaded, toGranularity: .second) == .orderedDescending
506505
} else {
507506
return false
508507
}

Sources/GateEngine/Resources/Skinning/Skeleton.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -706,9 +706,8 @@ extension ResourceManager {
706706
guard let path = Platform.current.synchronousLocateResource(from: key.requestedPath) else {return false}
707707
do {
708708
let attributes = try FileManager.default.attributesOfItem(atPath: path)
709-
if let modified = (attributes[.modificationDate] ?? attributes[.creationDate]) as? Date
710-
{
711-
return modified > cache.lastLoaded
709+
if let modified = (attributes[.modificationDate] ?? attributes[.creationDate]) as? Date {
710+
return Calendar.current.compare(modified, to: cache.lastLoaded, toGranularity: .second) == .orderedDescending
712711
} else {
713712
return false
714713
}

Sources/GateEngine/Resources/Texture/Texture.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ extension ResourceManager {
409409
do {
410410
let attributes = try FileManager.default.attributesOfItem(atPath: path)
411411
if let modified = (attributes[.modificationDate] ?? attributes[.creationDate]) as? Date {
412-
return modified > cache.lastLoaded
412+
return Calendar.current.compare(modified, to: cache.lastLoaded, toGranularity: .second) == .orderedDescending
413413
} else {
414414
return false
415415
}

Sources/GateEngine/Resources/Tiles/TileMap.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -403,9 +403,8 @@ extension ResourceManager {
403403
guard let path = Platform.current.synchronousLocateResource(from: key.requestedPath) else {return false}
404404
do {
405405
let attributes = try FileManager.default.attributesOfItem(atPath: path)
406-
if let modified = (attributes[.modificationDate] ?? attributes[.creationDate]) as? Date
407-
{
408-
return modified > cache.lastLoaded
406+
if let modified = (attributes[.modificationDate] ?? attributes[.creationDate]) as? Date {
407+
return Calendar.current.compare(modified, to: cache.lastLoaded, toGranularity: .second) == .orderedDescending
409408
} else {
410409
return false
411410
}

Sources/GateEngine/Resources/Tiles/TileSet.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,9 +341,8 @@ extension ResourceManager {
341341
guard let path = Platform.current.synchronousLocateResource(from: key.requestedPath) else {return false}
342342
do {
343343
let attributes = try FileManager.default.attributesOfItem(atPath: path)
344-
if let modified = (attributes[.modificationDate] ?? attributes[.creationDate]) as? Date
345-
{
346-
return modified > cache.lastLoaded
344+
if let modified = (attributes[.modificationDate] ?? attributes[.creationDate]) as? Date {
345+
return Calendar.current.compare(modified, to: cache.lastLoaded, toGranularity: .second) == .orderedDescending
347346
} else {
348347
return false
349348
}

0 commit comments

Comments
 (0)