Skip to content

Commit

Permalink
fix safari problem with year date math
Browse files Browse the repository at this point in the history
  • Loading branch information
arshaw committed Dec 25, 2018
1 parent a199727 commit 90eb3f6
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 16 deletions.
7 changes: 7 additions & 0 deletions src/datelib/marker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,13 @@ export function dateToUtcArray(date) {
}

export function arrayToUtcDate(a) {

// according to web standards (and Safari), a month index is required.
// massage if only given a year.
if (a.length === 1) {
a = a.concat([ 0 ])
}

return new Date(Date.UTC.apply(Date, a))
}

Expand Down
2 changes: 2 additions & 0 deletions tests/automated/datelib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,8 @@ describe('datelib', function() {

})

// test in Safari!
// https://github.com/fullcalendar/fullcalendar/issues/4363
it('startOfYear', function() {
var d0 = env.createMarker(new Date(Date.UTC(2018, 5, 5, 12)))
var d1 = env.toDate(env.startOfYear(d0))
Expand Down
51 changes: 35 additions & 16 deletions tests/automated/view-dates/dateAlignment.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,52 @@ import { expectActiveRange } from './ViewDateUtils'
/*
SEE ALSO: next/prev
*/
describe('dateAlignment', function() {
pushOptions({
defaultView: 'agenda',
dateAlignment: 'week',
defaultDate: '2017-06-15'
})
fdescribe('dateAlignment', function() {

describe('when 3 day duration', function() {
describe('when week alignment', function() {
pushOptions({
duration: { days: 3 }
defaultView: 'agenda',
dateAlignment: 'week',
defaultDate: '2017-06-15'
})

it('aligns with the week', function() {
initCalendar()
expectActiveRange('2017-06-11', '2017-06-14')
describe('when 3 day duration', function() {
pushOptions({
duration: { days: 3 }
})

it('aligns with the week', function() {
initCalendar()
expectActiveRange('2017-06-11', '2017-06-14')
})
})

describe('when 5 day count', function() {
pushOptions({
dayCount: 5,
weekends: false
})

it('aligns with first visible day of the week', function() {
initCalendar()
expectActiveRange('2017-06-12', '2017-06-17')
})
})
})

describe('when 5 day count', function() {
// test in Safari!
// https://github.com/fullcalendar/fullcalendar/issues/4363
describe('when year alignment', function() {
pushOptions({
dayCount: 5,
weekends: false
defaultView: 'basic',
duration: { months: 1 },
dateAlignment: 'year',
defaultDate: '2017-06-15'
})

it('aligns with first visible day of the week', function() {
it('aligns with first day of year', function() {
initCalendar()
expectActiveRange('2017-06-12', '2017-06-17')
expectActiveRange('2017-01-01', '2017-02-05')
})
})
})

0 comments on commit 90eb3f6

Please sign in to comment.