forked from diyaps/AndroidAPS
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'diyaps:master' into master
- Loading branch information
Showing
129 changed files
with
2,887 additions
and
275 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ version: 2.1 | |
# Orbs are reusable packages of CircleCI configuration that you may share across projects, enabling you to create encapsulated, parameterized commands, jobs, and executors that can be used across multiple projects. | ||
orbs: | ||
android: circleci/[email protected] | ||
codecov: codecov/codecov@3.2.4 | ||
codecov: codecov/codecov@3.3.0 | ||
|
||
jobs: | ||
# Below is the definition of your job to build and test your app, you can rename and customize it as you want. | ||
|
@@ -14,7 +14,7 @@ jobs: | |
executor: | ||
name: android/android-machine | ||
resource-class: large | ||
tag: 2023.07.1 | ||
tag: 2023.11.1 | ||
|
||
steps: | ||
- checkout | ||
|
@@ -34,11 +34,19 @@ jobs: | |
- android/run-tests: | ||
test-command: ./gradlew --stacktrace jacocoAllDebugReport | ||
|
||
# And finally run the release build | ||
# - run: | ||
# name: Assemble release build | ||
# command: | | ||
# ./gradlew assembleRelease | ||
- run: | ||
name: Save test results | ||
command: | | ||
mkdir -p ~/test-results/junit/ | ||
find . -type f -regex ".*/build/outputs/androidTest-results/.*xml" -exec cp {} ~/test-results/junit/ \; | ||
when: always | ||
|
||
- store_test_results: | ||
path: ~/test-results | ||
|
||
- store_artifacts: | ||
path: ~/test-results/junit | ||
|
||
- codecov/upload: | ||
file: './build/reports/jacoco/jacocoAllDebugReport/jacocoAllDebugReport.xml' | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
54 changes: 44 additions & 10 deletions
54
core/utils/src/main/kotlin/app/aaps/core/utils/MidnightUtils.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,56 @@ | ||
package app.aaps.core.utils | ||
|
||
import org.joda.time.DateTime | ||
import java.time.Duration | ||
import java.time.Instant | ||
import java.time.ZoneId | ||
import java.time.ZonedDateTime | ||
|
||
object MidnightUtils { | ||
/* | ||
/** | ||
* Midnight time conversion | ||
*/ | ||
object MidnightUtils { | ||
|
||
/** | ||
* Actual passed seconds from midnight ignoring DST change | ||
* (thus always having 24 hours in a day, not 23 or 25 in days where DST changes) | ||
* | ||
* @return seconds | ||
*/ | ||
fun secondsFromMidnight(): Int { | ||
val passed = DateTime().millisOfDay.toLong() | ||
return (passed / 1000).toInt() | ||
val nowZoned = ZonedDateTime.now() | ||
val localTime = nowZoned.toLocalTime() | ||
val midnight = nowZoned.toLocalDate().atStartOfDay(nowZoned.zone).toLocalTime() | ||
val duration = Duration.between(midnight, localTime) | ||
return duration.seconds.toInt() | ||
} | ||
|
||
fun secondsFromMidnight(date: Long): Int { | ||
val passed = DateTime(date).millisOfDay.toLong() | ||
return (passed / 1000).toInt() | ||
/** | ||
* Passed seconds from midnight for specified time ignoring DST change | ||
* (thus always having 24 hours in a day, not 23 or 25 in days where DST changes) | ||
* | ||
* @param timestamp time | ||
* @return seconds | ||
*/ | ||
fun secondsFromMidnight(timestamp: Long): Int { | ||
val timeZoned = ZonedDateTime.ofInstant(Instant.ofEpochMilli(timestamp), ZoneId.systemDefault()) | ||
val localTime = timeZoned.toLocalTime() | ||
val midnight = timeZoned.toLocalDate().atStartOfDay(timeZoned.zone).toLocalTime() | ||
val duration: Duration = Duration.between(midnight, localTime) | ||
return duration.seconds.toInt() | ||
} | ||
|
||
fun milliSecFromMidnight(date: Long): Long { | ||
return DateTime(date).millisOfDay.toLong() | ||
/** | ||
* Passed milliseconds from midnight for specified time ignoring DST change | ||
* (thus always having 24 hours in a day, not 23 or 25 in days where DST changes) | ||
* | ||
* @param timestamp time | ||
* @return milliseconds | ||
*/ | ||
fun milliSecFromMidnight(timestamp: Long): Long { | ||
val timeZoned = ZonedDateTime.ofInstant(Instant.ofEpochMilli(timestamp), ZoneId.systemDefault()) | ||
val localTime = timeZoned.toLocalTime() | ||
val midnight = timeZoned.toLocalDate().atStartOfDay(timeZoned.zone).toLocalTime() | ||
val duration = Duration.between(midnight, localTime) | ||
return duration.toMillis() | ||
} | ||
} |
Oops, something went wrong.