GithubHelp home page GithubHelp logo

ifc-service's Introduction

International Fixed Calendar MicroService

The International Fixed Calendar is a jersy/spring implementation of an International Fixed Calendar. It provides a gradle build to a shadow jar which can be deployed as a runnable jar.

The Problem

The International Fixed Calendar is a totally real calendar that has 13 months, each with 28 days. It synchronizes with the Gregorian calendar that most of us know and some of us love by sharing the same January 1st.

The months of the IFC are mostly the same as what you're used to:

  1. January
  2. February
  3. March
  4. April
  5. May
  6. June
  7. Sol
  8. July
  9. August
  10. September
  11. October
  12. November
  13. December

The Problem

NOTE The original requirements on this exrecise were seriously problematic, mostly because date offsets in the example didnt match the calendar api. This implementation normalizes the requirements.

We'd like to support the International Fixed Calendar in Java. Please implement the following API:

GregorianCalendar gregorianDate = new GregorianCalendar(2015, 0, 31);
IFCDate ifcDate = new IFCDate(date);

ifcDate.month
 #=> 1
ifcDate.day
 #=> 3

Because the year still needs to have 365 days, "Year Day" is always inserted as the 29th day of December:

GregorianCalendar gregorianDate = new GregorianCalendar(2015,11,31)
IFCDate ifcDate = new IFCDate(date);

ifc_date.month
 #=> 12
ifc_date.day
 #=> 29
ifc_date.year_day?
 #=> true

Similarly, in leap years, "Leap Day" is inserted as the 29th day of June:

GregorianCalendar gregorianDate = new GregorianCalendar(2016,5,17)
IFCDate ifcDate = new IFCDate(date);

ifc_date.month
#=> 5
ifc_date.day
#=> 29
ifc_date.leap_day?
#=> true

Runbook

Building the microservice container

bootstrap project for quickly making a webservices based project that uses spring, provides support for single jar runnable app. For more information on shadow jars goto [http://imperceptiblethoughts.com/shadow/](The ShadowJar Docs)

$ ./gradlew clean build shadowJar

Coburtura HTML Coverage Reports

Cobertura is used to generate coverage reports.

$ open build/reports/cobertura/index.html

Running your microservice

$ java -jar ./build/libs/ifc-app-0.0.1-SNAPSHOT-all.jar

Testing your IFC Service

$ curl -X POST \
    http://localhost:8080/rest/app/ifc/date \
    -H 'cache-control: no-cache' \
    -H 'content-type: application/json' \
    -d '{"gregorianYear":2015,"gregorianMonth":3,"gregorianDay":4}'

Leap Day

$ curl -X POST \
  http://localhost:8080/rest/app/ifc/date \
  -H 'cache-control: no-cache' \
  -H 'content-type: application/json' \
  -d '{"gregorianYear":2016,"gregorianMonth":5,"gregorianDay":17}'
   	
   	
{
  "gregorianYear": 2016,
  "gregorianMonth": 5,
  "gregorianDay": 17,
  "formattedDate": "17 Jun 2016",
  "dayOfYear": "169",
  "ifcDate": {
    "year": 2016,
    "month": 5,
    "day": 29,
    "leapDay": true,
    "yearDay": false
  }
}

Year Day

$ curl -X POST \
  http://localhost:8080/rest/app/ifc/date \
  -H 'cache-control: no-cache' \
  -H 'content-type: application/json' \
  -d '{"gregorianYear":2015,"gregorianMonth":11,"gregorianDay":31}'
  
 {
   "gregorianYear": 2015,
   "gregorianMonth": 11,
   "gregorianDay": 31,
   "formattedDate": "31 Dec 2015",
   "dayOfYear": "365",
   "ifcDate": {
     "year": 2015,
     "month": 12,
     "day": 29,
     "leapDay": false,
     "yearDay": true
   }
 } 

ifc-service's People

Contributors

claytantor avatar

Stargazers

Omar López 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.