Skip to content

Commit

Permalink
Merge pull request salahamassi#1 from rathodvikas10/master
Browse files Browse the repository at this point in the history
Fix leap year validation
  • Loading branch information
salahamassi authored Jun 6, 2020
2 parents 74e91cb + 11eb5a5 commit 7438dce
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 154 deletions.
41 changes: 32 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,36 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
.cxx

# Built application files
/*/build/
/build

# Local configuration file (sdk path, etc)
local.properties

# Gradle generated files
.gradle/

# OS-specific files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db

# User-specific configurations
*.iml
/.idea/*
/captures
.externalNativeBuild

# Built application files
*.apk
*.ap_

commitlint.config.js
node_modules/
package-lock.json
package.json
122 changes: 0 additions & 122 deletions .idea/codeStyles/Project.xml

This file was deleted.

19 changes: 0 additions & 19 deletions .idea/gradle.xml

This file was deleted.

2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {

}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
classpath 'com.android.tools.build:gradle:3.6.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
12 changes: 11 additions & 1 deletion dateedittext/src/main/java/com/msa/dateedittext/DateEditText.kt
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ class DateEditText : TextInputEditText {
}
}
//not Leap year
if (year % 100 != 0 || year % 400 != 0) {
if (isLeapYear(year).not()) {
val month = mValue.substring(3, 5).toInt()
val day = mValue.substring(0, 2).toInt()
if (month == 2 && day >= 28) {
Expand All @@ -365,6 +365,16 @@ class DateEditText : TextInputEditText {
return mValue
}

private fun isLeapYear(year: Int) = when {
year % 4 == 0 -> {
when {
year % 100 == 0 -> year % 400 == 0
else -> true
}
}
else -> false
}

/**
* validate user text input for MMyy Date Format
* @param value: String (user text input)
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon Jul 08 22:50:01 EEST 2019
#Thu Mar 05 15:59:31 IST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip

0 comments on commit 7438dce

Please sign in to comment.