Giter Club home page Giter Club logo

date-shortener's Introduction

date-shortener

A tool to shorten (encode) the date and expand (decode) shortened date back to original date

Introduction

Actually, I have developed a new way to encode/decode dates within 3 or 4 characters by using base-99 format. So here, we are going to learn about the logic behind this utility tool and reason of it's creation.

Why did I created it?

Actually, while sharing the files across organisation I would have to maintain version numbers in the filename but those versions won't tell anything about the last updation date until I check when was it last updated. So to maintain the updation dates in the filename, I had started adding timestamp in the filename which solved my issue but looks bad and it also increases the length of the filename. 

So I was searching ways to reduce the timestamp, at least the date portion to short string may be having only few characters but can tell the date. Initially, I got an idea of using base36 format instead of date and month because maximum date will be 31 which is less than 36; similary maximum month is 12 that is under 36 too. Well that solves my day-to-day problem but when I applied the same logic to years then it was limited to 36 years only. Then, I thought of using base64 format but that is also limited upto 64 years. 

Since I was looking for universal date conversion, so I would require something like base99 format. I looked over the Internet but I didn't found anything like that. So I made it by my own.

What is a base99 format?

In simple language, base99 format refers to series of 0-9 followed by small & capital A-Z characters and variations of vowel characters, i.e., 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZàèìòùÀÈÌÒÙáéíóúÁÉÍÓÚâêîôûÂÊÔÛÎäëïöüÄËÏ; where each character refers to the position index in series.

Using this format, any number in between 0-99 can be represented by a character positioned in base99 sequence

e.g., 12 → c, 19 → j, 34 → y

where, c is placed at 12th position in the sequence, j at 19th while y at 34th.

Now here is a way to use the same logic for date, so to do that let us take a date and encode it as

15-8-2019 → 15.8.2019 → f.8.kj → f8kj

Similarly, decode it back as

f8kj → f.8.kj → 15.8.2019 → 15-8-2019

Usage

Open the application in terminal & run the required commands as shown below

Examples

Few sample usages are given below

$ ds -t
2ckj
$ ds -t -s
2-12-2019 -> 2.12.2019 -> 2.c.kj -> 2ckj
$ ds -d 2ckj -s
2ckj -> 2.c.kj -> 2.12.2019 -> 2-12-2019
$ ds -e 2/12/2019 -s
2-12-2019 -> 2.12.2019 -> 2.c.kj -> 2ckj

Help

Find out all the available command options & flags

$ ds -h
Date Shortener is a tool to shorten (encode) the date and expand (decode) shortened date back to original date. 

Usage: ds [flag] [options]

Options:
    -d, --date DD-MM-YYYY
                        encode the provided date
    -c, --code DMY      decode the provided code
    -t, --today         encode today's date
    -e, --explain       explain with steps
    -h, --help          display the help menu
    -v, --version       display the application version

Examples: 
 $ ds -v 
 $ ds -t 
 $ ds -t -e 
 $ ds -d 15/08/2019 
 $ ds -d 15/08/2019 -e 
 $ ds -c f8j 
 $ ds -c f8j -e 

Version

See the currently available version

$ ds -v
Date Shortener 
Version 0.2.0 
Licensed under MIT License

Development

To generate the builds for all platforms at once, run this

$ sh builder.sh

Otherwise, to generate the build for particular platform and run below commands

Binaries

Create desktop builds that could run on shell.

Debug build

$ cd date-shortener
$ cargo build
$ ./target/debug/ds -h

Release build

$ cd date-shortener
$ cargo build --release
$ ./target/release/ds -h

WASI/WAPM

Create WASM file that could run using

In order to build it, we first need to install a WASI-enabled Rust toolchain:

$ rustup target add wasm32-wasi

Debug build

$ cd date-shortener
$ cargo build --target wasm32-wasi
$ file ./target/wasm32-wasi/debug/ds.wasm
$ wapm run ds -v

Release build

$ cd date-shortener
$ cargo build --target wasm32-wasi --release
$ file ./target/wasm32-wasi/release/ds.wasm
$ wapm run ds -v

Note: wapm runtime reserves these flags, so these gets override if app have it as well.

    -h, --help       Prints help information
    -V, --version    Prints version information

Although, WebAssembly.sh doesn't override any command or flag; where the ds commands can be used straight-forward.

References

date-shortener's People

Contributors

isurfer21 avatar

Watchers

 avatar  avatar

date-shortener's Issues

Cannot run package using Wasmer

Hi, I found your package on wapm and thought it would be fun to try it out!

I installed your package with:

wapm install isurfer21/date-shortener

Looking at your toml file, I found out that the program name is ds, so I ran this, as from the examples in the README page:

$ wapm run ds -t        
thread 'main' panicked at 'not yet implemented', /Users/abhishekkumar/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.42/src/sys.rs:102:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
Error: wasm trap occured: unknown

Not sure if this is a bug on your package, on wasmer, or what... just thought I should let you know.. would be interested in knowing why it fails.

Cheers!

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.