1.0.1 • Published 9 years ago

hextime v1.0.1

Weekly downloads
5
License
ISC
Repository
github
Last release
9 years ago

hextime

The time based on powers of 16. See the bottom for usage.

How do we normally divide units of time?

These are the seconds, minutes, hours, and days you grew up with. Here's a a little chart describing how many of a smaller unit fits into a larger unit:

Number of1 second1 minute1 hour1 day
seconds in:160360086400
minutes in:1601440
hours in:124
days in:1

As you can see, there are:

  • 60 seconds per minute, 3600 seconds per hour, 86400 seconds per day
  • 60 minutes per hour, 1440 minutes per day
  • 24 hours in a day

You already know this, even if you never thought about it...You count 60 seconds for 1 minute, 60 minutes for 1 hour.

But does it seem a little arbitrary to have to count 24 hours for 1 day? Maybe it does...Most of us grew up with that system and we accept it.

If you like numbers and/or the uneven partitioning of the day bothers you, read on.

What is hexadecimal time?

Hexadecimal time is an alternative way of measuring time, based on 16. One hexadecimal day is equal to one 'regular' day.

In hexadecimal time, the proportions of a smaller division of time to a larger unit of time is based on 16. Here, they are represented, decimally:

Number of1 hex second1 hex minute1 hex hour1 hex day
hex seconds in:116409665536
hex minutes in:12564096
hex hours in:116
hex days in:1

Here are the relationships, when you convert the above values to base-16

Number of1 hex second1 hex minute1 hex hour1 hex day
hex seconds in:110100010000
hex minutes in:11001000
hex hours in:110
hex days in:1

Pretty cool, huh?

Read more about hexadecimal time

Installation

npm install hextime

Usage

All numbers are expressed in base-10.

Convert from regular units of time to hexadecimal units of time

var fromRegular = require('hextime').fromRegular;

// convert regular seconds to a hexadecimal seconds
fromRegular.toHexSec(86400);

// convert regular minutes to hexadecimal minutes
fromRegular.toHexMin(1440);

// convert regular hours a hexadecimal hours
fromRegular.toHexHour(24);

Convert from hexadecimal units of time to regular units of time

var fromHexadecimal = require('hextime').fromHexadecimal;

// convert hexadecimal seconds to a regular seconds
fromHexadecimal.toRegSec(42);

// convert hexadecimal minutes to a regular minutes
fromHexadecimal.toRegMin(42);

// convert hexadecimal hours a regular hours
fromHexadecimal.toRegHour(16);

Use HexTime like a class

var HexTime = require('hextime').HexTime;

// convert from regular time to hexadecimal time by passing it the
// regular time as a string
HexTime.convertToHexTime('12:00:00');

// get hexadecimal hours from hexadecimal seconds
HexTime.getHHfromSS(65536);
// get hexadecimal days from hexadecimal minutes
HexTime.getDDfromMM(4096);
// get hexadecimal days from hexadecimal seconds
HexTime.getDDfromSS(65536);
1.0.1

9 years ago

1.0.0

9 years ago