Sync README.md sample code with actually tested code.

This commit is contained in:
Gwendal Roué committed 2015-09-25 08:34:49 +02:00
1 parent ff9b2c8bda
commit 05264d4ba9
2 files changed
+2 -1

No files matched your search

@@ -34,6 +34,7 @@ struct DatabaseTimestamp: DatabaseValueConvertible {
// Double itself adopts DatabaseValueConvertible. So let's avoid
// handling the raw DatabaseValue, and use built-in Double conversion:
guard let timeInterval = Double.fromDatabaseValue(databaseValue) else {
// No Double, no NSDate!
return nil
}
return DatabaseTimestamp(NSDate(timeIntervalSince1970: timeInterval))
+1 -1
View File
@@ -615,7 +615,7 @@ struct DatabaseTimestamp: DatabaseValueConvertible {
/// Returns a value that can be stored in the database.
var databaseValue: DatabaseValue {
return .Real(date.timeIntervalSince1970)
return DatabaseValue(double: date.timeIntervalSince1970)
}
/// Returns an instance initialized from *databaseValue*, if possible.