Giter VIP home page Giter VIP logo

date-calculator's Introduction

DATE CALCULATOR

Environment

This app is build base on nodejs. If you don't have nodejs installed in your system, here is the instruction.

Start the app

To run the app, you just need to simply type npm start, then the app will ask input (start and end date), enter the dates then you will see the result.

> npm start

> [email protected] start /Users/zhefeng/development/date-calculator
> node .

Please enter the start date (DD/MM/YYYY):
11/12/2015
Please enter the end date (DD/MM/YYYY):
22/12/2015
11/12/2015 - 22/12/2015: 10 days

Test the app

To run the test script, you need to install some dependencies, in this app, we using Mocha to do the test. So just type npm install, then all dependencies will be installed.

> npm install

npm WARN package.json [email protected] No license field.
npm WARN deprecated [email protected]: graceful-fs version 3 and before will fail on newer node releases. Please update to graceful-fs@^4.0.0 as soon as possible.
[email protected] node_modules/mocha
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] ([email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected], [email protected])
└── [email protected] ([email protected], [email protected], [email protected])

After install the dependencies, we can start to do the test, in this app, all you need to do is type npm test.

> npm test

> [email protected] test /Users/zhefeng/development/date-calculator
> mocha



  Calculator
    count days
      ✓ calculate the number of full days elapsed
      ✓ should never counted the first and the last day
      ✓ should count 0 if end date is before or equal the start date

  Utilities
    parseDate
      ✓ should return null if format not in DD/MM/YYYY. (eg. asdfasdf/asdf, asdfsdf)
      ✓ should return null if day, month or year is not an integer. (eg. 12/dd/1999)
      ✓ should return null if day, month or year is not a valid date number. (eg. 55/55/1999)
    formatDate
      ✓ should convert date object into to string with format DD/MM/YYYY
      ✓ should fill the 0 into interger under 10. (eg. 1/4/2015 - 01/04/2015)


  8 passing (13ms)

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.