diff --git a/MTMR/Info.plist b/MTMR/Info.plist
index fbf5da0..6a68148 100644
--- a/MTMR/Info.plist
+++ b/MTMR/Info.plist
@@ -17,9 +17,9 @@
CFBundlePackageType
APPL
CFBundleShortVersionString
- 0.23
+ 0.23.1
CFBundleVersion
- 275
+ 278
LSApplicationCategoryType
public.app-category.utilities
LSMinimumSystemVersion
diff --git a/MTMR/ItemsParsing.swift b/MTMR/ItemsParsing.swift
index 0861aca..8ed9452 100644
--- a/MTMR/ItemsParsing.swift
+++ b/MTMR/ItemsParsing.swift
@@ -344,7 +344,7 @@ enum ItemType: Decodable {
case staticButton(title: String)
case appleScriptTitledButton(source: SourceProtocol, refreshInterval: Double)
case shellScriptTitledButton(source: SourceProtocol, refreshInterval: Double)
- case timeButton(formatTemplate: String, timeZone: String?)
+ case timeButton(formatTemplate: String, timeZone: String?, locale: String?)
case battery()
case dock(autoResize: Bool)
case volume()
@@ -374,6 +374,7 @@ enum ItemType: Decodable {
case api_key
case icon_type
case formatTemplate
+ case locale
case image
case url
case longUrl
@@ -428,7 +429,8 @@ enum ItemType: Decodable {
case .timeButton:
let template = try container.decodeIfPresent(String.self, forKey: .formatTemplate) ?? "HH:mm"
let timeZone = try container.decodeIfPresent(String.self, forKey: .timeZone) ?? nil
- self = .timeButton(formatTemplate: template, timeZone: timeZone)
+ let locale = try container.decodeIfPresent(String.self, forKey: .locale) ?? nil
+ self = .timeButton(formatTemplate: template, timeZone: timeZone, locale: locale)
case .battery:
self = .battery()
diff --git a/MTMR/TouchBarController.swift b/MTMR/TouchBarController.swift
index 944fc7a..b0c5578 100644
--- a/MTMR/TouchBarController.swift
+++ b/MTMR/TouchBarController.swift
@@ -25,7 +25,7 @@ extension ItemType {
return "com.toxblh.mtmr.appleScriptButton."
case .shellScriptTitledButton(source: _):
return "com.toxblh.mtmr.shellScriptButton."
- case .timeButton(formatTemplate: _, timeZone: _):
+ case .timeButton(formatTemplate: _, timeZone: _, locale: _):
return "com.toxblh.mtmr.timeButton."
case .battery():
return "com.toxblh.mtmr.battery."
@@ -255,8 +255,8 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
barItem = AppleScriptTouchBarItem(identifier: identifier, source: source, interval: interval)
case let .shellScriptTitledButton(source: source, refreshInterval: interval):
barItem = ShellScriptTouchBarItem(identifier: identifier, source: source, interval: interval)
- case let .timeButton(formatTemplate: template, timeZone: timeZone):
- barItem = TimeTouchBarItem(identifier: identifier, formatTemplate: template, timeZone: timeZone)
+ case let .timeButton(formatTemplate: template, timeZone: timeZone, locale: locale):
+ barItem = TimeTouchBarItem(identifier: identifier, formatTemplate: template, timeZone: timeZone, locale: locale)
case .battery():
barItem = BatteryBarItem(identifier: identifier)
case let .dock(autoResize: autoResize):
diff --git a/MTMR/Widgets/TimeTouchBarItem.swift b/MTMR/Widgets/TimeTouchBarItem.swift
index 18c56bc..4a1df35 100644
--- a/MTMR/Widgets/TimeTouchBarItem.swift
+++ b/MTMR/Widgets/TimeTouchBarItem.swift
@@ -4,8 +4,11 @@ class TimeTouchBarItem: CustomButtonTouchBarItem {
private let dateFormatter = DateFormatter()
private var timer: Timer!
- init(identifier: NSTouchBarItem.Identifier, formatTemplate: String, timeZone: String? = nil) {
+ init(identifier: NSTouchBarItem.Identifier, formatTemplate: String, timeZone: String? = nil, locale: String? = nil) {
dateFormatter.dateFormat = formatTemplate
+ if let locale = locale {
+ dateFormatter.locale = Locale(identifier: locale)
+ }
if let abbr = timeZone {
dateFormatter.timeZone = TimeZone(abbreviation: abbr)
}
diff --git a/README.md b/README.md
index c03e948..de013e9 100644
--- a/README.md
+++ b/README.md
@@ -196,11 +196,14 @@ To close a group, use the button:
#### `timeButton`
> Attention! Works not all: https://en.wikipedia.org/wiki/List_of_time_zone_abbreviations
+> formatTemplate examples: https://www.datetimeformatter.com/how-to-format-date-time-in-swift/
+> locale examples: https://gist.github.com/jacobbubu/1836273
```js
{
"type": "timeButton",
"formatTemplate": "dd HH:mm",
+ "locale": "en_GB",
"timeZone": "UTC"
}
```