Skip to content
This repository has been archived by the owner on Jun 19, 2018. It is now read-only.

Is it possible to get the displayed date range? #390

Closed
z3ntu opened this issue Jul 13, 2016 · 7 comments
Closed

Is it possible to get the displayed date range? #390

z3ntu opened this issue Jul 13, 2016 · 7 comments

Comments

@z3ntu
Copy link

z3ntu commented Jul 13, 2016

Screenshot
For example in this view is it possible to get the dates 26.06. & 06.08. ?

EDIT: Apparently vm.view is used internally although I don't know if it is possible to access this.

@mattlewis92
Copy link
Owner

You can easily calculate this yourself with moment:

// where $scope.calendarDate is the variable you pass to the `view-date` option, and $scope.view is the variable you pass to the `view` option:
var start = moment($scope.calendarDate).startOf($scope.view).toDate();
var end = moment($scope.calendarDate).endOf($scope.view).toDate();

Internally this is all the calendar does as well. Hope that helps! 😄

@z3ntu
Copy link
Author

z3ntu commented Jul 14, 2016

I don't think that's what I wanted.
Your solution returns Fri Jul 01 2016 00:00:00 GMT+0200 (CEST) as start and Sun Jul 31 2016 23:59:59 GMT+0200 (CEST) as end, which is the start and the end of the month, but not the "displayed ones" (which are those days in the previous and next month which are still shown).

@mattlewis92
Copy link
Owner

OK, try:

var start = moment($scope.calendarDate).startOf('month').startOf('week').toDate();
var end = moment($scope.calendarDate).endOf('month').endOf('week').toDate();

@z3ntu
Copy link
Author

z3ntu commented Jul 14, 2016

Works perfectly, thanks!!

Mon Jun 27 2016 00:00:00 GMT+0200 (CEST) - Sun Jul 31 2016 23:59:59 GMT+0200 (CEST)

(I also changed the start of the week to monday)

@z3ntu
Copy link
Author

z3ntu commented Jul 15, 2016

I have one more question:
Is it possible to get a string from angular-translate (either possible via filter, service or directive) into the calendarConfig.i18nStrings.weekNumber variable (or directly display it in the HTML)?
I already tried using a custom calendarMonthCell.html and getting a string from my controller into this view, although it seems that this is not possible.
I tried {{'WEEK' | translate}} {week} what would be perfect, but I can't figure out a way to assign this resulting string to a variable (or directly use it with the <span ng-bind="weekString.replace('{week}', day.date.clone().add(1, 'day').isoWeek())"></span> line where there is some problem with using all those single and double quotes, it would be something like this: ng-bind="'{{'WEEK' | translate}} {week}'.replace().

I hope you understand what this wall of words mean and I hope you can help me :)

@mattlewis92
Copy link
Owner

On more thought, not very easily, I've made a new ticket to track it here: #393

@z3ntu
Copy link
Author

z3ntu commented Jul 15, 2016

Thanks!

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

No branches or pull requests

2 participants