Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from rehannali/develop
— Added extension to Date with milliseconds. — remove warning for shadow generics
- Loading branch information
Showing
7 changed files
with
137 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
## What type of PR is this? (check all applicable) | ||
|
||
- [ ] Refactor | ||
- [ ] Feature | ||
- [ ] Bug Fix | ||
- [ ] Optimization | ||
- [ ] Documentation Update | ||
|
||
## Description | ||
|
||
_Please replace this line with a description of what this PR does, and why._ | ||
|
||
## Related Issues Tickets | ||
|
||
- Related Issue # | ||
- Closes # | ||
|
||
## Instructions, Screenshots, Recordings (If Applicable) | ||
|
||
_Please replace this line with instructions on how to test your changes, a note | ||
on the devices this has been tested on, as well as any relevant instructions._ | ||
|
||
## Added/updated tests? | ||
_We encourage you to keep the code coverage percentage at 80% and above._ | ||
|
||
- [ ] Yes | ||
- [ ] No, They aren't needed. | ||
- [ ] No, I need help with writing tests. | ||
|
||
## [optional] Other information: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
Sources/SGSerializable/TransformableExtention/MilliSecondsToDate.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// | ||
// MilliSecondsToDate.swift | ||
// SGSerializable | ||
// | ||
// Created by Rehan Ali on 02/11/2023 at 12:49 AM. | ||
// Copyright © 2022 Rehan Ali. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
public struct MilliSecondsToDate: SGTranformable { | ||
public typealias FromType = TimeInterval | ||
public typealias ToType = Date | ||
|
||
public static func transform(from value: TimeInterval?) -> Date? { | ||
guard let value = value else { return nil } | ||
return Date(timeIntervalSince1970: value / 1000) | ||
} | ||
|
||
public static func transform(from value: Date?) -> TimeInterval? { | ||
guard let value = value else { return nil } | ||
return value.timeIntervalSince1970 * 1000 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters