Skip to content
This repository has been archived by the owner on Jan 22, 2023. It is now read-only.

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonas Schubert committed Jan 28, 2019
2 parents 1e255ac + 5480304 commit b3c49db
Show file tree
Hide file tree
Showing 11 changed files with 168 additions and 33 deletions.
76 changes: 76 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at [[email protected]]. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq
23 changes: 23 additions & 0 deletions COLLABORATING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Collaborator team rules and guidelines for community moderation

**As a contributor/member of the community, remember that you can always open issues about moderation and problems with how community moderation is done. We are always open to constructive criticism and feedback!**

## Responsibilities of a collaborator

As a member of the team that manages **TimeXt-Kotlin**, you have the following responsibilities:

- **Be part of the conversation in the issue tracker.** That includes (but is not limited to) helping out new members, discussing new features and explaining decisions to people.
- **Review pull requests.** You do not have to read through all of the pull requests and review them, but taking the time each day to review a few can help a great deal.
- **Be civil and polite.** If you are about to lose your temper, take a step back and do something else. We want our interactions with the community to be polite so that more people can join the project and contribute in any way they can. Remember to always thank contributors for their help, even if it's minor changes or changes that did not make it into the project. This way we can reward and encourage people to keep being part of the community.
- **Contribute when you want, moderate when you can.** If you have a lot on your plate outside of this project, it's alright. It's better to take a break for a few days rather than hastily deal with issues and pull requests that might break things.

## Guidelines for merging pull requests and making changes to the project

- **[Usual guidelines](CONTRIBUTING.md) apply.** Make sure to follow them, like everybody else.
- **For a pull request to be considered ready to merge, there should be at least 1 (preferably 2) reviews approving it for merge.** There are, however, certain exceptions:
- **If a pull request only fixes typos**, there is no need to wait for a second reviewer (unless you are not certain these were not typos in the first place).
- **If a pull request only clarifies a snippet's description or enforces the style guide for an existing snippet**, you might be able to merge it without getting a second reviewer to review it, but only if you are certain about it.
- **Changes to build scripts, guidelines and things that might break the processes we have in place need to be reviewed by [@GuepardoApps](https://github.com/GuepardoApps)** (this is temporary, but we need a baseline to make sure we break as few things as possible in the beginning).
- **After merging a pull request, make sure to check for untagged snippets and tag them appropriately.** Try to keep all snippets tagged, so that the list and website are up to date.
- **If you make changes or additions to existing snippets or if you want to add your own snippets, you will go through the pull request process that everyone else goes.** Exceptions apply similarly to the ones mentioned above about merging pull requests (i.e. typos, description clarification and the way script and build process changes are handled). Pull requests suggested by collaborators should be reviewed by at least two other collaborators to be considered ready to merge.
- **Pull requests that are inactive for over a week should be closed or put on hold.**
31 changes: 16 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
<a target="_blank" href="https://www.paypal.me/GuepardoApps" title="Donate using PayPal"><img src="https://img.shields.io/badge/paypal-donate-blue.svg" /></a>

[![](https://jitpack.io/v/TimeXt/TimeXt-Kotlin.svg)](https://jitpack.io/#TimeXt/TimeXt-Kotlin)
[![Version](https://img.shields.io/badge/version-v0.3.1.181129-blue.svg)](https://github.com/TimeXt/TimeXt-Kotlin/releases/tag/v0.3.1)
[![Version](https://img.shields.io/badge/version-v0.4.0.190128-blue.svg)](https://github.com/TimeXt/TimeXt-Kotlin/releases/tag/v0.4.0)
[![Build](https://img.shields.io/badge/build-success-green.svg)](timext)
[![CodeCoverage](https://img.shields.io/badge/codeCoverage-71-orange.svg)](timext)
[![CodeCoverage](https://img.shields.io/badge/codeCoverage-61-orange.svg)](timext)

[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](http://makeapullrequest.com)

Expand Down Expand Up @@ -37,6 +37,7 @@ val difference = date2 - date1

```kotlin
// Type is TimeXt
val threeYears = 3.years
val oneWeek = 1.weeks
val threeDays = 3.days
val elevenHours = 11.hours
Expand Down Expand Up @@ -105,24 +106,24 @@ handler.postDelayed({
If you would like to have your own timext unit, implement it as followed:

```kotlin
val year: Double = 365 * 24 * 60 * 60 * 1e3
val microsecond: Double = 1e-3

// Add also some extensions:
val Number.years: TimeXt
get() = TimeXt(this.toDouble(), year)
val Number.microseconds: TimeXt
get() = TimeXt(this.toDouble(), microsecond)

val TimeXt.inYears: TimeXt
get() = this.value * this.unit / year
val TimeXt.inMicroseconds: TimeXt
get() = this.value * this.unit / microsecond

fun toYears(): TimeXt {
return TimeXt(this.inYears, year)
fun toMicroseconds(): TimeXt {
return TimeXt(this.inMicroseconds, microsecond)
}

// Use it like:
val threeYears = TimeXt(3, year)
val oneYear = 1.years
val daysInYear = 365.days.inYears
val yearsFromDays = 365.days.toYears()
val threeMicroseconds = TimeXt(3, microsecond)
val oneMicroseconds = 1.microseconds
val secondInMicroseconds = 1.seconds.inMicroseconds
val microsecondsFromMinutes = 1.minutes.toMicroseconds()

```

Expand All @@ -144,15 +145,15 @@ Add the dependency to your `build.gradle`:

```groovy
dependencies {
implementation 'com.github.TimeXt.TimeXt-Kotlin:timext:v0.3.1'
implementation 'com.github.TimeXt.TimeXt-Kotlin:timext:v0.4.0'
}
```

- For **Android** projects:

```groovy
dependencies {
implementation 'com.github.TimeXt.TimeXt-Kotlin:timext-android:v0.3.1'
implementation 'com.github.TimeXt.TimeXt-Kotlin:timext-android:v0.4.0'
}
```

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ buildscript {
ext.gradle_version = '3.3.0'
ext.jacoco_coverage_version = '0.4.0'
ext.junit_version = '4.12'
ext.kotlin_version = '1.3.11'
ext.kotlin_version = '1.3.20'
ext.maven_gradle_version = '2.0'

repositories {
Expand Down
4 changes: 2 additions & 2 deletions timext-android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ android {
defaultConfig {
minSdkVersion 14
targetSdkVersion 28
versionCode 301
versionName "0.3.1.181129"
versionCode 400
versionName "0.4.0.190128"
}

buildTypes {
Expand Down
23 changes: 13 additions & 10 deletions timext-android/timext-android.iml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<compilerSettings />
<compilerArguments>
<option name="destination" value="$MODULE_DIR$/build/tmp/kotlin-classes/debug" />
<option name="classpath" value="$MODULE_DIR$/../timext/build/libs/timext.jar;C:/Users/Jonas/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk8/1.3.10/71d0fa967493eb76648b575edf1762cb2d0c7f10/kotlin-stdlib-jdk8-1.3.10.jar;C:/Users/Jonas/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.3.10/4d147bf43060dc43d61b096e24da1e67dfe0c032/kotlin-stdlib-jdk7-1.3.10.jar;C:/Users/Jonas/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.3.10/b178c1501609c6e4ee8be635513cb023a466457d/kotlin-stdlib-1.3.10.jar;C:/Users/Jonas/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.3.10/1b19d99229dcedad7caf50534dce38fe82845269/kotlin-stdlib-common-1.3.10.jar;C:/Users/Jonas/.gradle/caches/modules-2/files-2.1/org.jetbrains/annotations/13.0/919f0dfe192fb4e063e7dacadee7f8bb9a2672a9/annotations-13.0.jar;C:/Users/Jonas/AppData/Local/Android/Sdk/platforms/android-28/android.jar" />
<option name="classpath" value="$MODULE_DIR$/../timext/build/libs/timext.jar;C:/Users/Jonas/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk8/1.3.11/dd9bff00d6cfca58b6c1fe89be8e0678e35cf35f/kotlin-stdlib-jdk8-1.3.11.jar;C:/Users/Jonas/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.3.11/4839661cf6ce3c14b65ed7dcf5b9249b44ecca16/kotlin-stdlib-jdk7-1.3.11.jar;C:/Users/Jonas/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.3.11/4cbc5922a54376018307a731162ccaf3ef851a39/kotlin-stdlib-1.3.11.jar;C:/Users/Jonas/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.3.11/d8b8e746e279f1c4f5e08bc14a96b82e6bb1de02/kotlin-stdlib-common-1.3.11.jar;C:/Users/Jonas/.gradle/caches/modules-2/files-2.1/org.jetbrains/annotations/13.0/919f0dfe192fb4e063e7dacadee7f8bb9a2672a9/annotations-13.0.jar;C:/Users/Jonas/AppData/Local/Android/Sdk/platforms/android-28/android.jar" />
<option name="noStdlib" value="true" />
<option name="noReflect" value="true" />
<option name="moduleName" value="timext-android_debug" />
Expand All @@ -41,6 +41,9 @@
<option name="pluginClasspaths">
<array />
</option>
<option name="errors">
<ArgumentParseErrors />
</option>
</compilerArguments>
</configuration>
</facet>
Expand All @@ -51,16 +54,15 @@
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/not_namespaced_r_class_sources/debug/generateDebugRFile/out" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/aidl_source_output_dir/debug/compileDebugAidl/out" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/renderscript_source_output_dir/debug/compileDebugRenderscript/out" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/aidl_source_output_dir/debugAndroidTest/compileDebugAndroidTestAidl/out" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/renderscript_source_output_dir/debugAndroidTest/compileDebugAndroidTestRenderscript/out" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/test/debug" isTestSource="true" generated="true" />
Expand Down Expand Up @@ -114,6 +116,7 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/annotations_typedef_file" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/annotations_zip" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/check-manifest" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/check_manifest_result" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/consumer_proguard_file" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javac" />
Expand All @@ -137,10 +140,10 @@
</content>
<orderEntry type="jdk" jdkName="Android API 28 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Gradle: org.jetbrains.kotlin:kotlin-stdlib-common:1.3.10@jar" level="project" />
<orderEntry type="library" name="Gradle: org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.10@jar" level="project" />
<orderEntry type="library" name="Gradle: org.jetbrains.kotlin:kotlin-stdlib:1.3.10@jar" level="project" />
<orderEntry type="library" name="Gradle: org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.10@jar" level="project" />
<orderEntry type="library" name="Gradle: org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.11@jar" level="project" />
<orderEntry type="library" name="Gradle: org.jetbrains.kotlin:kotlin-stdlib-common:1.3.11@jar" level="project" />
<orderEntry type="library" name="Gradle: org.jetbrains.kotlin:kotlin-stdlib:1.3.11@jar" level="project" />
<orderEntry type="library" name="Gradle: org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.11@jar" level="project" />
<orderEntry type="library" name="Gradle: org.jetbrains:annotations:13.0@jar" level="project" />
<orderEntry type="module" module-name="timext" />
</component>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ package com.github.guepardoapps.timext.kotlin

class TimeXt(var value: Double, private var unit: Double) {

val inYears: Double
get() = this.value * this.unit / TimeXtUnit.year

val inWeeks: Double
get() = this.value * this.unit / TimeXtUnit.week

Expand All @@ -20,6 +23,10 @@ class TimeXt(var value: Double, private var unit: Double) {
val inMilliseconds: Double
get() = this.value * this.unit / TimeXtUnit.millisecond

fun toYears(): TimeXt {
return TimeXt(this.inYears, TimeXtUnit.year)
}

fun toWeeks(): TimeXt {
return TimeXt(this.inWeeks, TimeXtUnit.week)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.github.guepardoapps.timext.kotlin

object TimeXtUnit {
const val year: Double = 365 * 24 * 60 * 60 * 1e3

const val week: Double = 7 * 24 * 60 * 60 * 1e3

const val day: Double = 24 * 60 * 60 * 1e3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ package com.github.guepardoapps.timext.kotlin.extensions
import com.github.guepardoapps.timext.kotlin.TimeXt
import com.github.guepardoapps.timext.kotlin.TimeXtUnit

val Number.years: TimeXt
get() = TimeXt(this.toDouble(), TimeXtUnit.year)

val Number.weeks: TimeXt
get() = TimeXt(this.toDouble(), TimeXtUnit.week)

Expand Down
Loading

0 comments on commit b3c49db

Please sign in to comment.