How to use spacetime - 4 common examples

To help you get started, we’ve selected a few spacetime 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 spencermountain / compromise / plugins / dates / src / parse / toDate / units / Unit.js View on Github external
before() {
    this.d = spacetime.now() // ???
    return this
  }
  // 'after 2019'
github spencermountain / compromise / plugins / dates / src / parse / toDate / tokenize / 02-time.js View on Github external
const parseTime = function(doc) {
  let time = doc.match('(at|by|for|before)? #Time+')
  if (time.found) {
    doc.remove(time)
  }
  // get the main part of the time
  time = time.not('(at|by|for|before|sharp)')
  time = time.not('on the dot')
  let s = spacetime.now()
  let now = s.clone()

  // '5 oclock'
  let m = time.match('^#Cardinal oclock (am|pm)?')
  if (m.found) {
    m = m.not('oclock')
    s = s.hour(m.text('reduced'))
    if (s.isValid() && !s.isEqual(now)) {
      return s.time()
    }
  }

  // 'quarter to two'
  m = time.match('(half|quarter|25|15|10|5) (past|after|to) #Cardinal')
  if (m.found) {
    s = halfPast(m, s)
github ritoplz / ritoplz / pages / signup.js View on Github external
static async getInitialProps() {
    const translations = await getTranslation('pt', 'common')
    const now = spacetime().hour()
    const greeting = await goot(now)
    return { greeting, translations }
  }
github ritoplz / ritoplz / pages / login.js View on Github external
static async getInitialProps() {
    const translations = await getTranslation('pt', 'common')
    const now = spacetime().hour()
    const greeting = await goot(now)
    return { greeting, translations }
  }

spacetime

figure-out dates across timezones

Apache-2.0
Latest version published 1 month ago

Package Health Score

89 / 100
Full package analysis

Popular spacetime functions