-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
grenos
committed
Apr 4, 2020
1 parent
db5b277
commit f16d6d7
Showing
5 changed files
with
69 additions
and
1 deletion.
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
Binary file modified
BIN
+1.47 KB
(100%)
...odeproj/project.xcworkspace/xcuserdata/vasilis.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
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,21 @@ | ||
// | ||
// Date+Ext.swift | ||
// GHFollowers | ||
// | ||
// Created by Vasileios Gkreen on 04/04/2020. | ||
// Copyright © 2020 Vasileios Gkreen. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
|
||
extension Date { | ||
|
||
func convertToMonthYearFormat() -> String { | ||
let dateFormatter = DateFormatter() | ||
dateFormatter.dateFormat = "MMM yyyy" | ||
|
||
return dateFormatter.string(from: self) | ||
} | ||
|
||
} |
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,34 @@ | ||
// | ||
// String+Ext.swift | ||
// GHFollowers | ||
// | ||
// Created by Vasileios Gkreen on 04/04/2020. | ||
// Copyright © 2020 Vasileios Gkreen. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
|
||
// EXTENSION TO GET A DATE STRING FROM SERVER AND CONVERT IT TO A DIFERNET TYPE OF DATE FORMAT | ||
// the first part converts the string taken from the server to a Date format | ||
|
||
extension String { | ||
|
||
|
||
// this function returns a Date? which is optioanl | ||
func convertToDate() -> Date? { | ||
|
||
let dateFormatter = DateFormatter() | ||
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssZ" | ||
dateFormatter.locale = Locale(identifier: "en_US_POSIX") | ||
dateFormatter.timeZone = .current | ||
|
||
return dateFormatter.date(from: self) | ||
} | ||
|
||
|
||
func convertToDisplayFormat() -> String { | ||
guard let date = self.convertToDate() else {return "N/A"} | ||
return date.convertToMonthYearFormat() | ||
} | ||
} |
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