jonsamp / date-streaks

Find a variety of streak metrics from a list of dates
MIT License
49 stars 7 forks source link

Longest Streak Bug #1

Closed pauldps closed 5 years ago

pauldps commented 5 years ago

Given the following dates:

[
  new Date("2013-04-17T04:13:31.000Z"),
  new Date("2013-06-16T02:13:31.000Z"),
  new Date("2013-06-23T08:13:31.000Z"),
  new Date("2013-09-28T01:13:31.000Z"),
  new Date("2013-11-11T17:13:31.000Z"),
  new Date("2014-07-13T08:13:31.000Z"),
  new Date("2015-07-15T15:13:31.000Z"),
  new Date("2015-10-03T06:13:31.000Z"),
  new Date("2016-03-05T10:13:31.000Z"),
  new Date("2016-04-18T00:13:31.000Z")
]

The summary given is:

{
  currentStreak: 0,
  longestStreak: 0,
  streaks: [ 1 ],
  todayInStreak: false,
  withinCurrentStreak: false 
}

Where longestStreak should be 1.

pauldps commented 5 years ago

Please disregard. I was calling summary(dates) instead of summary({dates}).

Maybe the API could be more friendly if it also accepted a dates array as well as an object.