From c36d2fdcca2cad536a6964f06a4ea336ec4ab837 Mon Sep 17 00:00:00 2001
From: Oliver Yasuna
Date: Mon, 2 Sep 2024 16:05:06 -0400
Subject: [PATCH 1/2] docs: add @oliveryasuna as a contributor
---
.all-contributorsrc | 27 ++++++++++++---------------
README.md | 17 ++++++++++-------
2 files changed, 22 insertions(+), 22 deletions(-)
diff --git a/.all-contributorsrc b/.all-contributorsrc
index 592ee58..4226e71 100644
--- a/.all-contributorsrc
+++ b/.all-contributorsrc
@@ -3,9 +3,7 @@
"projectOwner": "capacitor-community",
"repoType": "github",
"repoHost": "https://github.com",
- "files": [
- "README.md"
- ],
+ "files": ["README.md"],
"imageSize": 75,
"commit": true,
"commitConvention": "angular",
@@ -16,31 +14,30 @@
"name": "Stew",
"avatar_url": "https://avatars1.githubusercontent.com/u/719763?v=4",
"profile": "https://twitter.com/StewanSilva",
- "contributions": [
- "code",
- "doc"
- ]
+ "contributions": ["code", "doc"]
},
{
"login": "danielprrazevedo",
"name": "Daniel Pereira",
"avatar_url": "https://avatars2.githubusercontent.com/u/20153661?v=4",
"profile": "https://github.com/danielprrazevedo",
- "contributions": [
- "code",
- "doc",
- "maintenance"
- ]
+ "contributions": ["code", "doc", "maintenance"]
},
{
"login": "carolineoliva",
"name": "Caroline Oliva",
"avatar_url": "https://avatars1.githubusercontent.com/u/4886893?v=4",
"profile": "https://github.com/carolineoliva",
- "contributions": [
- "code"
- ]
+ "contributions": ["code"]
+ },
+ {
+ "login": "oliveryasuna",
+ "name": "Oliver Yasuna",
+ "avatar_url": "https://avatars.githubusercontent.com/u/17092333?v=4",
+ "profile": "https://github.com/oliveryasuna",
+ "contributions": ["code"]
}
],
"contributorsPerLine": 7
}
+
diff --git a/README.md b/README.md
index 65c5674..859dd4f 100644
--- a/README.md
+++ b/README.md
@@ -12,7 +12,7 @@
-
+
@@ -301,14 +301,17 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
-
+
From 6c02288a4b119feab64a60fc53901b6d391943c1 Mon Sep 17 00:00:00 2001
From: Oliver Yasuna
Date: Mon, 2 Sep 2024 16:07:08 -0400
Subject: [PATCH 2/2] 88. Added support for iOS yearAndMonth.
---
example/src/app/home/home.page.ts | 12 +++++++++++-
ios/Plugin/DatePicker.swift | 9 +++++++++
src/definitions.ts | 5 +++--
3 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/example/src/app/home/home.page.ts b/example/src/app/home/home.page.ts
index 970ae69..ca4ec97 100644
--- a/example/src/app/home/home.page.ts
+++ b/example/src/app/home/home.page.ts
@@ -66,6 +66,10 @@ export class HomePage implements OnInit {
value: 'dateAndTime',
label: 'Date and Time',
},
+ {
+ value: 'yearAndMonth',
+ label: 'Year and Month',
+ },
];
async ngOnInit(): Promise {
@@ -131,7 +135,13 @@ export class HomePage implements OnInit {
options.ios.style = this.wheels ? 'wheels' : null;
}
console.log(options);
- return DatePicker.present(options);
+ const result = DatePicker.present(options);
+
+ result.then(({value: string}): void => {
+ alert(`Value: ${string}`);
+ });
+
+ return result;
}
async platformIs(
diff --git a/ios/Plugin/DatePicker.swift b/ios/Plugin/DatePicker.swift
index 29734e2..ad6d6f5 100644
--- a/ios/Plugin/DatePicker.swift
+++ b/ios/Plugin/DatePicker.swift
@@ -125,6 +125,13 @@ public class DatePicker {
picker.datePickerMode = UIDatePicker.Mode.dateAndTime
} else if options.mode == "date" || options.mode == "dateAndTime" {
picker.datePickerMode = UIDatePicker.Mode.date
+ } else if options.mode == "yearAndMonth" {
+ if #available(iOS 17.4, *) {
+ picker.datePickerMode = UIDatePicker.Mode.yearAndMonth
+ } else {
+ picker.datePickerMode = UIDatePicker.Mode.date
+ picker.datePickerMode = UIDatePicker.Mode.init(rawValue: 4269) ?? UIDatePicker.Mode.date
+ }
} else {
picker.datePickerMode = UIDatePicker.Mode.time
}
@@ -259,6 +266,8 @@ public class DatePicker {
format = options.is24h || is24h ? "HH:mm" : "hh:mm a"
} else if self.options.mode == "date" {
format = "E, MMM d, yyyy"
+ } else if options.mode == "yearAndMonth" {
+ format = "MMM yyyy"
}
return Parse.dateToString(date: date, format: format, locale: locale)
}
diff --git a/src/definitions.ts b/src/definitions.ts
index cb1b572..49df004 100644
--- a/src/definitions.ts
+++ b/src/definitions.ts
@@ -1,4 +1,4 @@
-export type DatePickerMode = 'time' | 'date' | 'dateAndTime' | 'countDownTimer';
+export type DatePickerMode = 'time' | 'date' | 'dateAndTime' | 'countDownTimer' | 'yearAndMonth';
export type DatePickerTheme = 'light' | 'dark' | string;
export type DatePickerIosStyle = 'wheels' | 'inline';
@@ -26,7 +26,8 @@ export interface DatePickerBaseOptions {
* @type {DatePickerMode}
* @default "dateAndTime"
*
- * @description Datepicker mode
+ * @description Datepicker mode.
+ * `yearAndMonth` is only available for iOS.
*/
mode?: DatePickerMode;
/**