Giter VIP home page Giter VIP logo

phpdatechallenge's Introduction

Avanti PHP Test

Calculate the difference between two given dates without using any of the PHP date functions, objects or packages not written by yourself.

This includes:

Assumptions

  • Dates will be provided in the format “YYYY/MM/DD” for example “2015/03/21”.
  • All dates will be based on the Gregorian calendar.
  • There should be a single interface for calculating the difference in the format:
$difference = MyDate::diff($start, $end);
  • The return value should be an object in the format:
stdClass {
    int   $years,        // The number of years between the two dates.
    int   $months,       // The number of months between the two dates less the years.
    int   $days,         // The number of days between the two dates less the months and the years.
    int   $total_days,   // The total days between the two dates including the months and years.
    bool  $invert        // true if the the difference is negative (i.e. $start > $end).
}
  • You are free to structure the rest of your code however you like and will be asked to explain your decisions.
  • Basic unit tests are provided however you are free to add tests to cover anything additional you feel is required.

Requirements

Getting Started

  • Fork and clone this repository
  • From the root run composer install
  • Start with the src/MyDate.php file and code until you are satisfied
  • ZIP up your solution and send it in

Testing

Basic unit tests are provided in the tests folder. To run these steps simply run:

phpunit --bootstrap= src/autoload.php tests/MyDateTest.php

Notes

If you create new class files be sure to update the src/autoload.php file to load these for the tests.

phpdatechallenge's People

Watchers

Christophe 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.