Giter Club home page Giter Club logo

timeformatter's Introduction

TimeFormatter

Example Code Demonstrating a Way to Format Time.

This is a Gradle project. You will find the source code under the src/main directory and the test code under the src/test directory.

Problem Statement

Without using any built-in date or time functions, write a function or method that accepts two mandatory arguments: the first argument is a 12-hour time string with the format "[H]H:MM {AM|PM}", and the second argument is a (signed) integer. The second argument is the number of minutes to add to the time of day represented by the first argument. The return value should be a string of the same format as the first argument. For example, AddMinutes("9:13 AM", 200) would return "12:33 PM". The exercise isn't meant to be too hard or take very long; we just want to see how you code. Use any mainstream language you want, though Java, Javascript (ES2017), Ruby, Swift, Python, C++ or C# are particularly relevant to us. Please include any test cases that you write.

Solution

The source code for the solution is located in the src/main/java/com/example/TimeFormatter.java file. The source code for the unit tests is located in the src/test/groovy/com/example/TimeFormatterSpec.groovy file.

Run the Test Cases

From the project directory run the following from the command line.

./gradlew clean test --info

This will run the tests and create a report in the $PROJECT_DIR/build/reports/tests/test directory. Load the $PROJECT_DIR/build/reports/tests/test/index.html into your browser to view the report.

IDEA Support

If you want to import this project into IntelliJ IDEA select Open Project and navigate to the build.gradle file.

To run the test file make sure the src/test/groovy directory is marked as a test source then right click on the src/test/groovy/com/example/TimeFormatterSpec file in the Project window and select Run TimeFormatterSpec.

timeformatter's People

Contributors

robbugh avatar

Watchers

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