Skip to content

Accuracy #19

@igneus

Description

@igneus

Recently I was debugging code which relied on TimeDifference when computing difference in days between two Dates. It turned out that code like

TimeDifference.between(
  Date.new(2015, 3, 15), 
  Date.new(2015, 4, 14)
).in_days.to_i

returns on different platforms different results. Having read how TimeDifference makes the calculations (dividing difference in seconds by an approximate length of a year / month / day / ... in seconds) I'm not surprised any more by the results, but for the sake of others tempted to make the same mistake I suggest being more explicit in the README concerning accuracy: TimeDifference is great for quick calculations where no accuracy is required (how long is it since I wrote my blog post?), but unsuitable for accurate computations (for how many days of using the service will I be billed?).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions