GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - taystack/get-date: Collection of native Date utilities to replace Moment.js

BranchesTags
Open more actions menu

Latest commit

 

History

47 Commits
47 Commits

Folders and files

NameName
Last commit message
Last commit date
__tests__
__tests__
 
 
docs
docs
 
 
scripts
scripts
 
 
source
source
 
 
.eslintrc
.eslintrc
 
 
.gitignore
.gitignore
 
 
.npmignore
.npmignore
 
 
README.md
README.md
 
 
codecov.yml
codecov.yml
 
 
jest.config.ts
jest.config.ts
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 
tsconfig.json
tsconfig.json
 
 
typedoc.js
typedoc.js
 
 
webpack.config.ts
webpack.config.ts
 
 

Repository files navigation

Javascript getDate

codecov npm

Documentation

Play on Runkit

Why?

Moment.js has been retired. It had math operations on dates. I think Math is helpful on Dates.

With moment

import moment from 'moment'
const now = Date.now()
const today = moment.utc(now)
const momentYesterday = today.subtract(1, 'days')

With @taystack/getDate:

import { getDate, subtractDays } from '@taystack/get-date' // es6
// const { getDate, subtractDays } = require('@taystack/get-date') // es5
const now = Date.now()
const today = getDate(now)
const getDateYesterday = subtractDays(now, 1)

What else?

There are no dependencies. This is a small set of helpers for working with native Javascript Date objects.

Installation

npm i @taystack/get-date

API

  • Getters
    • getDate
    • getDates
    • getTime
    • getDateInputValue
    • getStartOfDay
    • getTimeString
  • Equality
    • eq
    • gt
    • gte
    • lt
    • lte
  • Math
    • addDays
    • addHours
    • addMilliseconds
    • addMinutes
    • addSeconds
    • addStep
    • subtractDays
    • subtractHours
    • subtractMilliseconds
    • subtractMinutes
    • subtractSeconds
    • subtractStep
  • Humanize
    • humanizeDay
    • humanizeDifference
    • humanizeMonth
    • humanizeStep
  • TimeDelta
    • difference
    • exclusiveRange
    • inclusiveRange
    • range
  • helpers
    • leftPad
    • pluralize

Getters

getDate

getDate documentation

import { getDate } from '@taystack/get-date'
getDate()
// Same as new Date()
getDate(0)
// new Date(0) -> jan 1 1970

getTime

getTime documentation

import { getTime } from '@taystack/get-date'
getTime()
// Same as Date.now()
getTime(0)
// 0 -> Short-hand new Date(0).getTime()

About

Collection of native Date utilities to replace Moment.js

Topics

datedaterangedatetimedatetimeformatno-dependenciestimedeltavanilla-javascript

Resources

Readme
Activity

Stars

1 star

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.