-
-
Save GuilhE/45e67f1f41e83ef0d9c4e3d77d7bcec1 to your computer and use it in GitHub Desktop.
Medium articles - What's Native
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
import Foundation | |
import SharedModule | |
func formatDateTimeWithLocale(date: Kotlinx_datetimeLocalDate, pattern: String) -> String { | |
let formatter = DateFormatter() | |
formatter.dateFormat = pattern | |
formatter.locale = Locale.current | |
return formatter.string(from: date.toDate()) | |
} | |
extension Kotlinx_datetimeLocalDate { | |
func toDate() -> Date { | |
var components = DateComponents() | |
components.year = Int(self.year) | |
components.month = Int(self.monthNumber) | |
components.day = Int(self.dayOfMonth) | |
return Calendar.current.date(from: components)! | |
} | |
} | |
//will print for example 09 Março, 09 March, 3月9日... | |
let sharedObject = SharedObjectsProvider().sharedObject() | |
print(formatDateTimeWithLocale(date: sharedObject.currentDate, pattern: "dd MMMM")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment