Skip to content

Commit

Permalink
1.2.0
Browse files Browse the repository at this point in the history
* add full date pattern for android

* update docs

* update README

* update CHANGELOG

* bump version to 1.2.0
  • Loading branch information
Nikoro authored Feb 14, 2024
1 parent 4b3299e commit 185fc16
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 70 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.2.0

Added `full date pattern` for android

## 1.1.2

- Updated README info about -> [`system_date_time_format_hook`](https://pub.dev/packages/system_date_time_format_hook) package
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ Future<void> main() async {
final format = SystemDateTimeFormat();
final datePattern = await format.getDatePattern();
final mediumDatePattern = await format.getMediumDatePattern();
final mediumDatePattern = await format.getMediumDatePattern(); // Not on Windows & Linux
final longDatePattern = await format.getLongDatePattern();
final fullDatePattern = await format.getFullDatePattern(); // available only on iOS, macOS and web
final fullDatePattern = await format.getFullDatePattern(); // Not on Windows & Linux
final timePattern = await format.getTimePattern();
print(datePattern); // e.g. "M/d/yy"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.dominikkrajcer.system_date_time_format
import android.content.Context
import android.text.format.DateFormat
import androidx.annotation.NonNull

import io.flutter.embedding.engine.plugins.FlutterPlugin
import io.flutter.plugin.common.MethodCall
import io.flutter.plugin.common.MethodChannel
Expand Down Expand Up @@ -31,7 +30,7 @@ class SystemDateTimeFormatPlugin : FlutterPlugin, MethodCallHandler {
"getDateFormat" -> result.success(getDateFormat())
"getMediumDateFormat" -> result.success(getMediumDateFormat())
"getLongDateFormat" -> result.success(getLongDateFormat())
"getFullDateFormat" -> result.success(null)
"getFullDateFormat" -> result.success(getFullDateFormat())
"getTimeFormat" -> result.success(getTimeFormat())
else -> result.notImplemented()
}
Expand All @@ -57,6 +56,12 @@ class SystemDateTimeFormatPlugin : FlutterPlugin, MethodCallHandler {
return (longDateFormat as SimpleDateFormat).toLocalizedPattern()
}

private fun getFullDateFormat(): String {
val locale = applicationContext.resources.configuration.locale
val fullDateFormat = java.text.DateFormat.getDateInstance(java.text.DateFormat.FULL, locale)
return (fullDateFormat as SimpleDateFormat).toLocalizedPattern()
}

private fun getTimeFormat(): String {
val timeFormat = DateFormat.getTimeFormat(applicationContext)
return (timeFormat as SimpleDateFormat).toLocalizedPattern()
Expand Down
62 changes: 31 additions & 31 deletions example/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
buildscript {
ext.kotlin_version = '1.7.20'
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:7.2.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

allprojects {
repositories {
google()
mavenCentral()
}
}

rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
delete rootProject.buildDir
}
buildscript {
ext.kotlin_version = '1.7.20'
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:7.2.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

allprojects {
repositories {
google()
mavenCentral()
}
}

rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}

tasks.register("clean", Delete) {
delete rootProject.buildDir
}
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ packages:
path: ".."
relative: true
source: path
version: "1.1.2"
version: "1.2.0"
term_glyph:
dependency: transitive
description:
Expand Down
62 changes: 31 additions & 31 deletions example_with_tests/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
buildscript {
ext.kotlin_version = '1.7.20'
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:7.2.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

allprojects {
repositories {
google()
mavenCentral()
}
}

rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
delete rootProject.buildDir
}
buildscript {
ext.kotlin_version = '1.7.20'
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:7.2.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

allprojects {
repositories {
google()
mavenCentral()
}
}

rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}

tasks.register("clean", Delete) {
delete rootProject.buildDir
}
2 changes: 1 addition & 1 deletion example_with_tests/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ packages:
path: ".."
relative: true
source: path
version: "1.1.2"
version: "1.2.0"
term_glyph:
dependency: transitive
description:
Expand Down
2 changes: 1 addition & 1 deletion lib/system_date_time_format.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class SystemDateTimeFormat {
}

/// Returns a full version of date pattern.
/// Available on iOS, macOS and web
/// Available on iOS, macOS, android and web
/// May throw [PlatformException] from [MethodChannel].
Future<String?> getFullDatePattern() async {
final pattern = await SystemDateTimeFormatPlatformInterface.instance
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: system_date_time_format
description: A plugin for getting date and time format patterns from device system settings.
version: 1.1.2
version: 1.2.0
repository: https://github.com/Nikoro/system_date_time_format
issue_tracker: https://github.com/Nikoro/system_date_time_format/issues

Expand Down

0 comments on commit 185fc16

Please sign in to comment.