How to use the d3-time.timeMinute.count function in d3-time

To help you get started, we’ve selected a few d3-time examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github orbiting / crowdfunding-frontend / components / Status / index.js View on Github external
render () {
    if (!this.props.crowdfunding) {
      return null
    }

    const {crowdfunding: {goals, status, endDate}, t} = this.props
    const now = new Date()
    const nextMinute = timeMinute.ceil(new Date())

    // end date is expected to be an exact minute
    // timeMinute.round is used to ensure that and
    // support end dates like '2017-05-31 19:59:59.999+02'
    const end = timeMinute.round(new Date(endDate))

    const totalMinutes = timeMinute.count(nextMinute, end)
    const minutes = totalMinutes % 60
    const hours = Math.floor(totalMinutes / 60) % 24
    const days = Math.floor(totalMinutes / 60 / 24)

    if (!goals.length) {
      return
    }

    const goalsByPeople = [].concat(goals)
      .sort((a, b) => ascending(a.people, b.people))
    const goal = goalsByPeople[goalsByPeople.length - 1]

    const peopleLabel = t.elements('status/goal/people', {
      count: (
        <a> {</a>
github orbiting / republik-frontend / components / CrowdfundingStatus / index.js View on Github external
crowdfundingName,
      crowdfunding: { goals, status },
      t,
      money,
      people,
      memberships
    } = this.props
    const now = new Date()
    const nextMinute = timeMinute.ceil(new Date())

    // end date is expected to be an exact minute
    // timeMinute.round is used to ensure that and
    // support end dates like '2017-05-31 19:59:59.999+02'
    const end = timeMinute.round(new Date(endDate))

    const totalMinutes = timeMinute.count(nextMinute, end)
    const minutes = totalMinutes % 60
    const hours = Math.floor(totalMinutes / 60) % 24
    const days = Math.floor(totalMinutes / 60 / 24)

    if (!goals.length) {
      return null
    }

    const goalsByPeople = []
      .concat(goals)
      .sort((a, b) =&gt; ascending(a.people, b.people))
    const goal = goalsByPeople[goalsByPeople.length - 1]

    const createHoverGoalCount = (format, value) =&gt; (
github orbiting / crowdfunding-frontend / components / Discuss / Comment.js View on Github external
isEditing: false
              })
            }} /&gt;
          <a href="#"> {
            e.preventDefault()
            this.setState({
              isEditing: false
            })
          }}&gt;{t('discuss/comment/editCancel')}</a>
        
      )
    }

    const createdAt = new Date(data.createdAt)
    const updatedAt = new Date(data.updatedAt)
    const updateOffset = timeMinute.count(createdAt, updatedAt)
    let updateNote
    if (updateOffset &gt; 2) {
      updateNote = t('discuss/comment/updateNote', {
        updateDate: dateTimeFormat(updatedAt)
      })
    }

    const commentColor = pollColors[tags[0]]

    return (
      <div data-comment="">
        {!!id &amp;&amp; (
          <div>
            </div></div>
github orbiting / republik-frontend / components / CrowdfundingStatus / index.js View on Github external
tick() {
    const now = new Date()

    const msLeft = 1000 - now.getMilliseconds() + 50
    let msToNextTick = (60 - now.getSeconds()) * 1000 + msLeft

    const endDate = this.props.endDate || this.props.crowdfunding.endDate
    if (endDate) {
      const end = new Date(endDate)
      if (end &lt; now) {
        return
      }
      const totalMinutes = timeMinute.count(now, end)
      const hours = Math.floor(totalMinutes / 60) % 24
      if (hours === 0) {
        msToNextTick = msLeft
      }
    }

    clearTimeout(this.timeout)
    this.timeout = setTimeout(() =&gt; {
      this.setState({
        now: new Date()
      })
      this.tick()
    }, msToNextTick)
  }
  componentDidMount() {
github orbiting / crowdfunding-frontend / components / Status / index.js View on Github external
render () {
    if ((this.props.loading || this.props.error) &amp;&amp; !this.props.crowdfunding) {
      return null
    }

    const {crowdfunding: {goals, status, endDate}, t} = this.props
    const now = new Date()
    const end = new Date(endDate)

    const totalMinutes = timeMinute.count(now, end)
    const minutes = totalMinutes % 60
    const hours = Math.floor(totalMinutes / 60) % 24
    const days = Math.floor(totalMinutes / 60 / 24)

    if (!goals.length) {
      return
    }

    const goalsByPeople = [].concat(goals)
      .sort((a, b) =&gt; ascending(a.people, b.people))
    const goal = goalsByPeople[goalsByPeople.length - 1]

    const peopleLabel = t.elements('status/goal/people', {
      count: (
        <a> {</a>
github orbiting / crowdfunding-frontend / components / Countdown.js View on Github external
render () {
    const {to} = this.props

    const now = new Date()

    if (now &gt; to) {
      return (<div style="{{margin:">
        Es ist Zeit.
      </div>)
    }

    const totalMinutes = timeMinute.count(now, to)
    const minutes = totalMinutes % 60
    const hours = Math.floor(totalMinutes / 60) % 24
    const days = Math.floor(totalMinutes / 60 / 24)

    return (
      <div style="{{textAlign:">
        <div>
          <figure>
            <div>{days}</div>
            <figcaption>
              {days === 1 ? 'Tag' : 'Tage'}
            </figcaption>
          </figure>
          <figure>
            <div>{hours}</div>
            <figcaption></figcaption></figure></div></div>
github orbiting / crowdfunding-frontend / components / Status / index.js View on Github external
tick () {
    const now = new Date()

    const msLeft = 1000 - now.getMilliseconds() + 50
    let msToNextTick = (60 - now.getSeconds()) * 1000 + msLeft

    const {crowdfunding: {endDate}} = this.props
    if (endDate) {
      const end = new Date(endDate)
      if (end &lt; now) {
        return
      }
      const totalMinutes = timeMinute.count(now, end)
      const hours = Math.floor(totalMinutes / 60) % 24
      if (hours === 0) {
        msToNextTick = msLeft
      }
    }

    clearTimeout(this.timeout)
    this.timeout = setTimeout(
      () =&gt; {
        this.setState({
          now: new Date()
        })
        this.tick()
      },
      msToNextTick
    )
github orbiting / crowdfunding-frontend / components / Vote / Poll.js View on Github external
{
        const endDate = new Date(voting.endDate)

        const reachedEndDate = now &gt; endDate

        const minutes = timeMinute.count(now, endDate)

        let timeLeft
        if (minutes &gt; 60 * 24) {
          timeLeft = {
            unit: 'days',
            count: Math.floor(minutes / 60 / 24)
          }
        } else if (minutes &gt; 60) {
          timeLeft = {
            unit: 'hours',
            count: Math.floor(minutes / 60)
          }
        } else {
          timeLeft = {
            unit: 'minutes',
            count: minutes