#!/bin/bash # stardate, date in hexadecimal or base36 or base62 # http://www.dcode.fr/base-n-convert # dec to hex hex () { var=$(printf '%x\n' "$1") echo ${var^^} } # hex to dec dec () { var="$1" echo $((0x$var)) } # epoch to time ep2time () { date -d @"$1" } # https://en.wikipedia.org/wiki/Base36#bash_implementation thirty () { value="$1" result="" base36="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" while true; do result=${base36:((value%36)):1}${result} if [ $((value=${value}/36)) -eq 0 ]; then break fi done echo ${result} } # base 62 sixty () { value="$1" result="" base62="0123456789aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ" while true; do result=${base62:((value%62)):1}${result} if [ $((value=${value}/62)) -eq 0 ]; then break fi done echo ${result} } normal=$(date +%s) # epoch in seconds = shortest #normal=$(date +%Y%m%d%H%M%S) # yyyymmddHHMMSS #normal="441796964000000000" # seconds from big-bang echo "$normal"; hex "$normal"; thirty "$normal"; sixty "$normal" #ep2time "$normal"