Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add addYears and addMonths #11

Merged
merged 1 commit into from
Apr 12, 2016
Merged

Add addYears and addMonths #11

merged 1 commit into from
Apr 12, 2016

Conversation

sheepsteak
Copy link
Contributor

I'm not sure if you left these out on purpose but I needed them and thought I would add them. I wasn't able to write them using addMilliseconds as obviously months and years can have a different amount of milliseconds in them.

@sheepsteak
Copy link
Contributor Author

I also seem to get failing tests locally on latest master (before my commit):

✓ sanity
✓ noon without input date
✓ noon with input date
✓ adding days
✓ adding hours
✓ adding minutes
✓ adding seconds
✓ adding milliseconds
⨯ differenceInDates
  not ok 28 should be equal
    ---
      operator: equal
      expected: 1
      actual:   0
      at: Test.<anonymous> (/Users/chris/Source/sheepsteak/instadate/test/main.js:79:5)
    ...
✓ differenceInDays
✓ differenceInWeekendDays
✓ differenceInHours
✓ differenceInMinutes
✓ differenceInSeconds
✓ isSameYear
✓ isSameMonth
✓ isSameDay
✓ dates
✓ equal
✓ dateString
✓ min
✓ max
⨯ firstDateInMonth
  not ok 82 should be equal
    ---
      operator: equal
      expected: |-
        'Fri Jan 01 2016 13:07:17 GMT+0200 (EET)'
      actual: |-
        'Fri Jan 01 2016 11:07:17 GMT+0000 (GMT)'
      at: Test.<anonymous> (/Users/chris/Source/sheepsteak/instadate/test/main.js:227:5)
    ...
⨯ lastDateInMonth
  not ok 83 should be equal
    ---
      operator: equal
      expected: |-
        'Sun Jan 31 2016 13:07:17 GMT+0200 (EET)'
      actual: |-
        'Sun Jan 31 2016 11:07:17 GMT+0000 (GMT)'
      at: Test.<anonymous> (/Users/chris/Source/sheepsteak/instadate/test/main.js:233:5)
    ...
✓ isWeekendDay
✓ isWeekendDate
✓ isWorkDay
✓ isWorkDate
✓ setWeekendDays
✓ daysInPeriod
✓ weekendDaysInPeriod
✓ workDaysInPeriod
✓ isAfter
✓ isBefore
✓ isYearAfter
✓ isYearBefore
✓ isMonthAfter
✓ isMonthBefore
⨯ isDayAfter
  not ok 171 (unnamed assert)
    ---
      operator: notOk
      expected: false
      actual:   true
      at: Test.<anonymous> (/Users/chris/Source/sheepsteak/instadate/test/main.js:417:5)
    ...
⨯ isDayBefore
  not ok 177 (unnamed assert)
    ---
      operator: ok
      expected: true
      actual:   false
      at: Test.<anonymous> (/Users/chris/Source/sheepsteak/instadate/test/main.js:429:5)
    ...
✓ isYearBetween
✓ isMonthBetween
✓ isDayBetween
✓ isoWeekDay
✓ isoDateString
# tests 205
# pass  200
⨯ fail  5

@sheepsteak
Copy link
Contributor Author

So I've found out what is causing the tests to fail but I don't understand why. I noticed you're doing everything in the EET timezone but my Mac is running in British English.

I'm getting some strange results like the following when using toString in Node 5.9.1 and Chrome Dev (51):

> new Date('Mon Jan 18 2016 13:07:17 GMT+0100 (BST)').toString()
'Mon Jan 18 2016 12:07:17 GMT+0000 (GMT)'
> new Date('Mon Jan 18 2016 14:07:17 GMT+0200 (EET)').toString()
'Mon Jan 18 2016 12:07:17 GMT+0000 (GMT)'
> new Date().toString()
'Fri Apr 01 2016 11:07:52 GMT+0100 (BST)'

It's forcing things into UTC unless I use the empty Date constructor.

@herkyl
Copy link
Contributor

herkyl commented Apr 1, 2016

Thanks for the PR! ✋

Yeah, I left them out because the days in months and years are changing.

Could you add some more tests to see what happens when you add 11/12 months for instance. Does the year change, will the month stay the same when adding 12 months?

Any ideas why your tests might be failing? In which timezone are you?

@herkyl
Copy link
Contributor

herkyl commented Apr 1, 2016

Good find! I don't have time right now to fix the timezone toString bug but I will take a look at it later.

@sheepsteak
Copy link
Contributor Author

Yeah, I will add more tests.

I noticed you have export TZ=Europe/Helsinki in your travis.yml. I tried this locally and the tests pass. I'm in Europe/London so that is why toString was outputting in GMT+0000 for me by default (even though we're in GMT+0100 daylight savings right now!). So TZ needs setting for npm test or all tests should use UTC. I'll make a separate issue about this so you can decide what you want.

@herkyl
Copy link
Contributor

herkyl commented Apr 1, 2016

Thanks!

@sheepsteak
Copy link
Contributor Author

Hi @herkyl, I've added the extra tests you wanted.

@herkyl herkyl merged commit aead59f into Teamweek:master Apr 12, 2016
@herkyl
Copy link
Contributor

herkyl commented Apr 12, 2016

Thanks! Published as 0.3.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants