Code Monkey home page Code Monkey logo

date_diff's People

Contributors

nithinstany avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

date_diff's Issues

Calculation check - not adding up

d1 = Date.parse("12-March-2020")
d2 = Date.parse("1-March-2024")

diff = Date.diff(d1, d2)

puts d1 + diff[:year].years + diff[:month].months + diff[:day].days

> Sun, 03 Mar 2024

Shouldn't the resulting date be 1 Mar 2024?

Thanks - I am probably missing something obvious, but suspect it is not taking in to account the leap year days.

not working with latest gems

Just did a gem update and then attempted the example from the wiki and get the following error: Below is a list of gems installed.

irb(main):001:0> require 'date_diff'
=> true
irb(main):002:0> Date.diff(Date.parse('2000-01-01'), Date.parse('2013-06-19'))
I18n::InvalidLocaleData: can not load translations from /usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.0/lib/active_support/locale/en.yml: #<NoMethodError: undefined method `load_file' for Psych:Module>
    from /usr/local/lib/ruby/gems/2.2.0/gems/i18n-0.7.0/lib/i18n/backend/base.rb:184:in `rescue in load_yml'
    from /usr/local/lib/ruby/gems/2.2.0/gems/i18n-0.7.0/lib/i18n/backend/base.rb:181:in `load_yml'
    from /usr/local/lib/ruby/gems/2.2.0/gems/i18n-0.7.0/lib/i18n/backend/base.rb:165:in `load_file'
    from /usr/local/lib/ruby/gems/2.2.0/gems/i18n-0.7.0/lib/i18n/backend/base.rb:15:in `block in load_translations'
    from /usr/local/lib/ruby/gems/2.2.0/gems/i18n-0.7.0/lib/i18n/backend/base.rb:15:in `each'
    from /usr/local/lib/ruby/gems/2.2.0/gems/i18n-0.7.0/lib/i18n/backend/base.rb:15:in `load_translations'
    from /usr/local/lib/ruby/gems/2.2.0/gems/i18n-0.7.0/lib/i18n/backend/simple.rb:57:in `init_translations'
    from /usr/local/lib/ruby/gems/2.2.0/gems/i18n-0.7.0/lib/i18n/backend/simple.rb:40:in `available_locales'
    from /usr/local/lib/ruby/gems/2.2.0/gems/i18n-0.7.0/lib/i18n/config.rb:43:in `available_locales'
    from /usr/local/lib/ruby/gems/2.2.0/gems/i18n-0.7.0/lib/i18n/config.rb:49:in `available_locales_set'
    from /usr/local/lib/ruby/gems/2.2.0/gems/i18n-0.7.0/lib/i18n.rb:278:in `locale_available?'
    from /usr/local/lib/ruby/gems/2.2.0/gems/i18n-0.7.0/lib/i18n.rb:284:in `enforce_available_locales!'
    from /usr/local/lib/ruby/gems/2.2.0/gems/i18n-0.7.0/lib/i18n.rb:151:in `translate'
    from /usr/local/lib/ruby/gems/2.2.0/gems/date_diff-0.0.4/lib/date_diff.rb:41:in `block in diff'
    from /usr/local/lib/ruby/gems/2.2.0/gems/date_diff-0.0.4/lib/date_diff.rb:39:in `each'
    from /usr/local/lib/ruby/gems/2.2.0/gems/date_diff-0.0.4/lib/date_diff.rb:39:in `diff'
    from (irb):2
    from /usr/local/bin/irb:11:in `<main>'irb(main):003:0> 
> gem list

*** LOCAL GEMS ***

activesupport (4.2.0)
awesome_print (1.6.1, 1.2.0)
bigdecimal (1.2.6)
chronic (0.10.2)
chronic_duration (0.10.6)
colored (1.2)
columnize (0.9.0)
command_line_reporter (3.3.2)
countries (0.9.3)
currencies (0.4.2)
date_diff (0.0.4)
dbd-mysql (0.4.4)
dbd-sqlite3 (1.2.5)
dbi (0.4.5)
deprecated (3.0.1, 2.0.1)
ffi (1.9.6)
i18n (0.7.0)
innate (2013.02.21)
io-console (0.4.3)
json (1.8.2, 1.8.1)
mail (2.6.3)
mailfactory (1.4.0)
mime-types (2.4.3)
minitest (5.5.1, 5.5.0)
mysql (2.9.1)
mysql2 (0.3.17)
numerizer (0.2.0, 0.1.1)
psych (2.0.10, 2.0.8)
rack (1.6.0, 1.5.2)
rake (10.4.2)
ramaze (2012.12.08)
rdoc (4.2.0)
ruby-progressbar (1.7.1)
ruby_info (1.0.1)
sequel (4.18.0, 4.17.0)
span (0.1.2)
sqlite3 (1.3.10)
sqlite3-ruby (1.3.3)
sys-cpu (0.7.1)
sys-filesystem (1.1.3)
sys-host (0.6.2)
sys-uname (0.9.2)
sys-uptime (0.6.2)
terminal-table (1.4.5)
thread_safe (0.3.4)
tzinfo (1.2.2)
unicode (0.4.4.2)
unicode_utils (1.4.0)

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.