mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 14:20:20 +00:00
Various improvements
This commit is contained in:
@@ -146,24 +146,13 @@ public func stringForCompactDate(timestamp: Int32, strings: PresentationStrings,
|
||||
return "\(shortStringForDayOfWeek(strings: strings, day: timeinfo.tm_wday)) \(timeinfo.tm_mday) \(monthAtIndex(Int(timeinfo.tm_mon), strings: strings))"
|
||||
}
|
||||
|
||||
public func stringForCompactBirthday(_ birthday: TelegramBirthday, strings: PresentationStrings) -> String {
|
||||
public func stringForCompactBirthday(_ birthday: TelegramBirthday, strings: PresentationStrings, showAge: Bool = false) -> String {
|
||||
var components: [String] = []
|
||||
components.append("\(birthday.day)")
|
||||
components.append(monthAtIndex(Int(birthday.month) - 1, strings: strings))
|
||||
if let year = birthday.year {
|
||||
components.append("\(year)")
|
||||
}
|
||||
|
||||
return components.joined(separator: " ")
|
||||
}
|
||||
|
||||
public func stringForFullBirthday(_ birthday: TelegramBirthday, strings: PresentationStrings, showAge: Bool = false) -> String {
|
||||
var components: [String] = []
|
||||
components.append("\(birthday.day)")
|
||||
components.append(stringForMonth(strings: strings, month: birthday.month - 1))
|
||||
if let year = birthday.year {
|
||||
components.append("\(year)")
|
||||
|
||||
|
||||
if showAge {
|
||||
var dateComponents = DateComponents()
|
||||
dateComponents.day = Int(birthday.day)
|
||||
@@ -173,7 +162,7 @@ public func stringForFullBirthday(_ birthday: TelegramBirthday, strings: Present
|
||||
let calendar = Calendar.current
|
||||
if let birthDate = calendar.date(from: dateComponents) {
|
||||
if let age = calendar.dateComponents([.year], from: birthDate, to: Date()).year {
|
||||
components.append("(\(age))")
|
||||
components.append("(\(strings.UserInfo_Age(Int32(age))))")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user