Giter VIP home page Giter VIP logo

hextime's Introduction

hextime

A toy app that shows the date and time using 13-month calendar and base-16 time.

What is base-16 time?

I made this up because of a comment thread about how "base 12 sucks" and we should represent time elsewise. I thought it'd be fun to just divide the day up using base-16. Using four digits, we can represent down to the seconds, unlike in normal "base 12" time where this requires 6 digits (hh:mm:ss).

In base-16 time, the first digit represents 1.5 hours, the second about 5 minutes and 38 seconds, the third about 21 seconds, and the fourth about 1.31 seconds.

What is the 13-month calendar?

The 13-month calendar is one that just takes the Gregorian calendar's year, splits it into 13 months of 28 days long (4-weeks exactly), and then takes any remaining days and puts at the end of the last month. Some versions of the 13-month calendar assert that the first day of the year is also always a Monday, and that eve-month basically is in day-of-the-week limbo.

Installation

For the applet showing the current time, save clock.c and hextime.c and clone tigr and then compile based on the system you're on; for me in Linux, that looks like gcc -o hexclock clock.c -lGLU -lGL -lX11. Specifically, make sure that the tigr.c and tigr.h files and the tigr/src folders are all in the top directory.

For the standalone clock applet, compile clock.c using gcc or clang.

For use within a project, save hextime.c and compile it using gcc or clang. I personally recommend just doing gcc -o hextime ./hextime.c. Compilation will depend on <stdlib.h>, <stdio.h>, <time.h>, <stdint.h>, and <string.h>.

Standalone Usage

clock will open a graphical window that displays the current date and time.

Import Usage

If you'd like to use this inside of another program, just #include "hextime.c".

currentTime()

currentTime takes no arguments and returns a regtime_t struct populated with the current local date and time.

regtime_str()

The regtime_str function expects to be passed int argc and char **argv. argc should be the length of argv. argv should store the string representations of each digit in the regular-time representation, starting at index 1 instead of 0, such as 4, [null, "02", "33", "16"] to represent 02:33 plus 16 sec, or 7, [null, "1999", "04", "01", "12", "41", "00"] to represent 12:41 plus 0 sec on April 1st, 1999.

hextime()

The hexTime function expects to be passed a regtime_t struct, which looks like

typedef struct {
    uint64_t year; uint64_t mon; uint64_t mday; uint64_t yday;
    uint64_t hour; uint64_t min; uint64_t sec;
} regtime_t;

and will return a hextime_t struct which looks like

typedef struct {
    uint64_t year;  uint64_t mon; uint64_t mday; uint64_t yday;
    uint64_t d1;    uint64_t d2;  uint64_t d3;   uint64_t d4;
} hextime_t;

print_hexTime

print_hexTime accepts a hextime_t struct and prints it out to stdout in a nice readable form.

hextime's People

Contributors

inolonger avatar johnalexco avatar

Stargazers

 avatar

Watchers

 avatar

hextime's Issues

seconds-digit sometimes shows "g" in clock or extra zero in cli

Example: 2e:cg from hexclock somewhere around 04:23"18. This issue doesn't seem replicateable from hextime,

hexclock $ ./hex 04 23 18
1 January 1900, 2e:cf
hexclock $ ./hex 04 23 18.5
1 January 1900, 2e:cf
hexclock $ ./hex 04 23 19
1 January 1900, 2e:c10

Issue only occurs occasionally, and elsewise the hexclock seems to be correctly tracking the time.

however, hextime adds an extra zero at the end of certain values while the clock shows the time correctly.

hexclock $ ./hex 04 26 50
1 January 1900, 2f:610

Outdated link and readme errors

Readme includes information about removed files, link on clock is to old outdated website. Thought there was an issue with leap time but the way the lib counts uses days-into-year so I don't think this issue really exists.

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.