Skip to content

Commit

Permalink
collapse months if hiding times
Browse files Browse the repository at this point in the history
  • Loading branch information
icambron committed Jul 2, 2016
1 parent 23b1639 commit 5c6baa9
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -4,6 +4,7 @@ test/coverage.html
*.bak
npm-debug.log
.DS_Store
.#*

#Jetbrains IDE files
.idea
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -4,7 +4,7 @@ language: node_js
node_js:
- 0.12
- 4.2.4
- 5.3.0
- 5.9.0

before_install:
- make configure
Expand Down
14 changes: 9 additions & 5 deletions dist/twix.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/twix.min.js

Large diffs are not rendered by default.

13 changes: 9 additions & 4 deletions src/twix.coffee
Expand Up @@ -248,6 +248,8 @@ makeTwix = (moment) ->
needDate = !options.hideDate &&
(!options.implicitDate || @start().startOf('d').valueOf() != moment().startOf('d').valueOf() || !(@isSame('d') || goesIntoTheMorning))

atomicMonthDate = !(@allDay || options.hideTime)

if @allDay && @isSame('d') && (options.implicitDate || options.explicitAllDay)
fs.push
name: 'all day simple'
Expand All @@ -262,22 +264,22 @@ makeTwix = (moment) ->
pre: ', '
slot: 4

if !@allDay && needDate
if atomicMonthDate && needDate
fs.push
name: 'all day month'
name: 'month-date'
fn: (date) -> date.format "#{options.monthFormat} #{options.dayFormat}"
ignoreEnd: -> goesIntoTheMorning
pre: ' '
slot: 2

if @allDay && needDate
if !atomicMonthDate && needDate
fs.push
name: 'month'
fn: (date) -> date.format options.monthFormat
pre: ' '
slot: 2

if @allDay && needDate
if !atomicMonthDate && needDate
fs.push
name: 'date'
fn: (date) -> date.format options.dayFormat
Expand Down Expand Up @@ -331,6 +333,9 @@ makeTwix = (moment) ->

start_group = {format: format, value: -> start_str}

if @_start.month() == 9 && @_start.date() == 6
console.log "Format: #{JSON.stringify(format)}"

if end_str == start_str && together
common_bucket.push start_group
else
Expand Down
2 changes: 1 addition & 1 deletion test/twix.spec.coffee
Expand Up @@ -1357,7 +1357,7 @@ test = (moment, Twix) ->
start: thisYear '05-25', '05:30'
end: thisYear '05-27', '06:30'
options: {hideTime: true}
result: 'May 25 - May 27'
result: 'May 25 - 27'

test 'hide times even for a single day',
start: thisYear '05-25', '05:30'
Expand Down

0 comments on commit 5c6baa9

Please sign in to comment.