Giter Site home page Giter Site logo

maolson0 / multiclock Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 4.62 MB

iOS clock that shows civil and solar time in hh:mm format, in metric, and as percent of day elapsed.

Home Page: https://www.olsons.net/projects/multiclock

Swift 100.00%
clock ios-app ios-swift ios-swift-ui utilities bsd-3-clause

multiclock's Introduction

MultiClock

iOS clock that shows civil and solar time in hh:mm format, in metric, and as percent of day elapsed.

This clock uses iOS location services to figure out the user's latitude and longitude. It uses OS services to get the current local time. It computes the solar time from the user's distance from the prime meridian (every minute of longitude is equivalent to four minutes' difference on the clock) and the equation of time (see https://en.wikipedia.org/wiki/Equation_of_time). I used an accurate (within 13 seconds anytime in the current century) and efficient calculation to approximate the equation of time from https://equation-of-time.info/calculating-the-equation-of-time.

The clock displays the current civil and solar times in traditional hh:mm format, and in a metric format. For the metric time, I divide the day into 10,000 equal-sized segments. Midnight is 0000 and the instant before the following midnight is 9999. A 24-hour day is 86,400 seconds long. Four digits means the smallest digit is equivalent to 100 microdays. Each 100-microday unit is 8.64 seconds long. The clock counts those as they pass and displays the current count. Finally, the percent-of-day elapsed is displayed as a progress bar. It occurred to me after working with metric time for a while that you could view the 4-digit metric time as a percentage, with a decimal point in the middle, so I added that display.

The MultiClock app now allows you to enter a time in any of the four forms -- civil or solar, hh:mm or metric -- and convert to all the rest. Civil-to-solar conversion depends on the Earth's position in its orbit around the sun, so the converter allows you to choose the date for which you want do to the conversion. It uses your current location for the calculation.

The MultiClock display changes when your phone is in landscape, instead of portrait, mode. It lays out the different parts of the time and converter views to take better advantage of the available screen real estate. In the case of the converter, you can choose whether you have left-handed or right-handed layout for the button keypad for entering times. That's in the iOS Settings app under the entry for MultiClock.

I use Chris Howell's excellent Solar library (https://github.com/ceeK/Solar) to calculate sunrise and sunset times, and display those for civil and solar hh:mm and metric times.

When any metric time on the display is a prime number, I highlight it in red. I'm crazy about primes. You can change this setting in the iOS Settings app, in the entry for MultiClock.

By default, the clock displays time in 12-hour AM/PM format. You can choose a 24-hour display in Preferences. If the iOS system setting for time display is a 24-hour clock, it will override the app's setting. You can change this in Settings as well.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.