Skip to content

suggestion: a better select-month emitter #5

Description

@alexfung888

Bug, feature request, or proposal:

proposal: returning month in a more useful format

What is the expected behavior?

returns '2017-03' instead of

What is the current behavior?

start=2017-03-01 0h0m0s local time
end= 2017-03-31 23h59m59s local time

What are the steps to reproduce?

switch to month mode and choose a month

Providing a Plunker (or similar) is the best way to get the team to see your issue.
Plunker template: http://plnkr.co/edit/o077B6uEiiIgkC0S06dd

What is the use-case or motivation for changing an existing behavior?

for easier extracting month/year of the selected month. Start/End is tricky, because ISO-STRING uses GMT and either start/end can easily move to previous/next month.

Which versions of Angular, Material, OS, browsers are affected?

any

Is there anything else we should know?

suggested code:

      newPeriod = {
        type: 'month',
        startDate: new Date(momentConstructor(entry.date).startOf('month').toDate().valueOf()),
        endDate: new Date(momentConstructor(entry.date).endOf('month').toDate().valueOf())
      };

      // add a new @output() selMonth:
      let sd = new Date(entry.date.valueOf() - entry.date.getTimezoneOffset()*60000);
      this.selMonth.emit(sd.toISOString().substr(0,7));

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions