Git Product home page Git Product logo

aligent-datechallenge's Introduction

#Solution for

1.Find out the number of days between two datetime parameters.

Usage php artisan datetime:days datetime1 datetime2

datetime1 and datetime2 should be of the format dd-mm-yyyy-hh-mm-ss

There is no space between yyyy and hh in the format. Introducing a space between them will split date and time into two different parameters

Usage example

php artisan datetime:days 01-01-2016-10-30-00 15-01-2016-11-00-00

2.Find out the number of weekdays between two datetime parameters. Usage php artisan datetime:weekdays datetime1 datetime2

datetime1 and datetime2 should be of the format dd-mm-yyyy-hh-mm-ss

Usage example

php artisan datetime:weekdays 01-01-2016-10-30-00 15-01-2016-11-00-00

3.Find out the number of complete weeks between two datetime parameters. Usage php artisan datetime:weeks datetime1 datetime2

datetime1 and datetime2 should be of the format dd-mm-yyyy-hh-mm-ss

Usage example

php artisan datetime:weeks 01-01-2016-10-30-00 15-01-2016-11-00-00

4.Accept a third parameter to convert the result of (1, 2 or 3) into one of seconds, minutes, hours, years. For all the above 3 commands adding an optional parameter --output=x will convert the result into the value required. Options for x are s convert the result in seconds i convert the result in minutes h convert the result in hours y convert the result in years

Usage example

php artisan datetime:days datetime1 datetime2 --output=s
php artisan datetime:weekdays datetime1 datetime2 --output=i
php artisan datetime:weeks datetime1 datetime2 --output=h
php artisan datetime:weeks datetime1 datetime2 --output=y

5.Allow the specification of a timezone for comparison of input parameters from different timezones.

Usage php artisan datetime:tz datetime1 datetime2 timezone1 timezone2

datetime1 and datetime2 should be of the format dd-mm-yyyy-hh-mm-ss timezone1 and timezone2 can be any standard time-zone string. Please refer to http://php.net/manual/en/timezones.php for list of valid time-zone strings

timezone1 is for datetime1 and timezone2 is for datetime2

Usage example

php artisan datetime:tz 01-01-2016-00-00-00 01-01-2016-00-00-00 Australia/Adelaide Australia/Melbourne
php artisan datetime:tz 01-01-2016-00-00-00 01-01-2016-12-30-30 Australia/Adelaide Australia/Melbourne

6.Check for DST time difference in hours for a specific timezone.

Usage php artisan datetime:dst datetime1 datetime2 timezone

datetime1 and datetime2 should be of the format dd-mm-yyyy-hh-mm-ss timezone can be any standard time-zone string. Please refer to http://php.net/manual/en/timezones.php for list of valid time-zone strings

Usage example

php artisan datetime:dst 01-04-2016-00-00-00 04-04-2016-00-00-00 Australia/Melbourne
php artisan datetime:dst 01-03-2016-00-00-00 04-03-2016-00-00-00 Australia/Melbourne

In the above examples, first command will return 73 hours and the second command will return 72 hours

Validate test cases by running phpunit from the command prompt

aligent-datechallenge's People

Contributors

shanprabu avatar

Watchers

 avatar

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.