Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

https://github.com/AlexanderJonsson/Swatch-Internet-Time

A very simple library for getting the current time as .beats "Swatch internet time"
https://github.com/AlexanderJonsson/Swatch-Internet-Time

beats futurism internet-time swatch time timekeeping timezones timing

Last synced: about 2 months ago
JSON representation

A very simple library for getting the current time as .beats "Swatch internet time"

Lists

README

        

# Swatch Internet Time Java Library
(README.md generated by ChatGPT)

This Java library provides a simple way to get the current time in Swatch Internet Time beats. Swatch Internet Time is a decimal time concept introduced by the Swatch Group in 1998, which divides the 24-hour day into 1,000 "beats", each beat lasting 1 minute and 26.4 seconds.

## Usage

To use the `InternetTime` class, first import it into your Java project:

```java
import se.alexanderjonsson.InternetTime;
```
Then, you can call one of the following static methods to get the current Swatch Internet Time:
```java
// Returns the current time as an Integer
int swatchTimeInt = InternetTime.getCurrentTimeAsInteger();

// Returns the current time as a Double with two decimal places
double swatchTimeDouble = InternetTime.getCurrentTimeAsDouble();

// Returns the current time as a formatted String
String swatchTimeStringWithDecimals = InternetTime.getCurrentTimeAsString(TimeFormat.WITH_DECIMALS); // e.g. "123.23"
String swatchTimeStringWithoutDecimals = InternetTime.getCurrentTimeAsString(TimeFormat.WITHOUT_DECIMALS); // e.g. "123"

// Returns a String representation of the current Swatch Internet Time in the format "@.beats"
String swatchTimeString = InternetTime.toString(); // e.g. "@009.23.beats"
```
Note that the getCurrentTimeAsString() method both allow you to specify a TimeFormat enum value to control the formatting of the returned value. The TimeFormat enum has four values: WITH_CENTIBEATS, WITHOUT_CENTIBEATS, CENTIBEATS_WITHOUT_LEADING_ZEROES, WITHOUT_CENTIBEATS_WITHOUT_LEADING_ZEROES. If you don't specify a TimeFormat, the default is WITH_CENTIBEATS.
```java
public enum TimeFormat {
WITH_CENTIBEATS,
WITHOUT_CENTIBEATS,
CENTIBEATS_WITHOUT_LEADING_ZEROES,
WITHOUT_CENTIBEATS_WITHOUT_LEADING_ZEROES;
}
```