Last active
April 19, 2017 05:30
-
-
Save david-duncan/c564810b10a42b93db590252f5d3647a to your computer and use it in GitHub Desktop.
current week only
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Ember from 'ember'; | |
| import computed from 'ember-computed'; | |
| import moment from 'moment'; | |
| export default Ember.Component.extend({ | |
| days: computed(function() { | |
| let now = moment(); | |
| let day = now.clone().startOf('week'); | |
| let lastDay = now.clone().endOf('week'); | |
| let days = []; | |
| while (day.isBefore(lastDay)) { | |
| let copy = day.clone(); | |
| let isCurrentMonth = copy.month() === now.month(); | |
| days.push({ date: copy._d, moment: copy, isCurrentMonth }); | |
| day.add(1, 'day'); | |
| } | |
| return days; | |
| }), | |
| currentWeek: computed('isShowingCurrentWeek', function() { | |
| let days = this.get('days'); | |
| let weeks = []; | |
| let i = 0; | |
| while (days[i]) { | |
| weeks.push({ days: days.slice(i, i + 5) }); | |
| i += 5; | |
| } | |
| return weeks; | |
| }) | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Ember from 'ember'; | |
| export default Ember.Controller.extend({ | |
| appName: 'Ember Twiddle' | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "version": "0.12.1", | |
| "EmberENV": { | |
| "FEATURES": {} | |
| }, | |
| "options": { | |
| "use_pods": false, | |
| "enable-testing": false | |
| }, | |
| "dependencies": { | |
| "jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
| "ember": "2.12.0", | |
| "ember-template-compiler": "2.12.0", | |
| "ember-testing": "2.12.0" | |
| }, | |
| "addons": { | |
| "ember-data": "2.12.1", | |
| "ember-power-calendar": "*" | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment