mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-29 04:24:21 +00:00
Minor tweaks
This commit is contained in:
1 parent
c8bad5db25
commit
edbd2e8d01
2 files changed
+10
-4
No files matched your search
@@ -10,6 +10,9 @@ import XCTest
|
||||
import GRDB
|
||||
|
||||
struct DatabaseDate: SQLiteValueConvertible {
|
||||
|
||||
// MARK: - DatabaseDate <-> NSDate conversion
|
||||
|
||||
let date: NSDate
|
||||
|
||||
// Define a failable initializer in order to consistently use nil as the
|
||||
@@ -22,12 +25,12 @@ struct DatabaseDate: SQLiteValueConvertible {
|
||||
}
|
||||
}
|
||||
|
||||
// Date -> SQLite
|
||||
// MARK: - DatabaseDate <-> SQLiteValue conversion
|
||||
|
||||
var sqliteValue: SQLiteValue {
|
||||
return .Real(date.timeIntervalSince1970)
|
||||
}
|
||||
|
||||
// SQLite -> Date
|
||||
init?(sqliteValue: SQLiteValue) {
|
||||
// Don't handle the raw SQLiteValue unless you know what you do.
|
||||
// It is recommended to use GRDB built-in conversions instead:
|
||||
|
||||
@@ -238,6 +238,9 @@ For example, let's define below the `DatabaseDate` type that stores and loads NS
|
||||
|
||||
```swift
|
||||
struct DatabaseDate: SQLiteValueConvertible {
|
||||
|
||||
// MARK: - DatabaseDate <-> NSDate conversion
|
||||
|
||||
let date: NSDate
|
||||
|
||||
// Define a failable initializer in order to consistently use nil as the
|
||||
@@ -250,12 +253,12 @@ struct DatabaseDate: SQLiteValueConvertible {
|
||||
}
|
||||
}
|
||||
|
||||
// Date -> SQLite
|
||||
// MARK: - DatabaseDate <-> SQLiteValue conversion
|
||||
|
||||
var sqliteValue: SQLiteValue {
|
||||
return .Real(date.timeIntervalSince1970)
|
||||
}
|
||||
|
||||
// SQLite -> Date
|
||||
init?(sqliteValue: SQLiteValue) {
|
||||
// Don't handle the raw SQLiteValue unless you know what you do.
|
||||
// It is recommended to use GRDB built-in conversions instead:
|
||||
|
||||
Reference in new issue
Block a user