GithubHelp home page GithubHelp logo

dates.nvim's Introduction

๐Ÿ“… Dates

An utility plugin to manage and process dates for Neovim.

โœจ Features

  • Check validity: Check if a date is valid.
  • Generate dates: Retrieve valid dates starting from a given year's beginning.
  • Get weekday: Obtain the weekday for a specified date.
  • Get dates from date to date: Retrieve all dates between two given dates.

๐Ÿš€ Usage

API

Check if a date is valid:

---@return boolean
require('dates').is_valid(year, month, day)

Get dates for a given prefix:

---@param prefix_to_filter string -- e.g., 2021-01 or 20.
---@return table -- array of suggested date strings
require('dates').get(prefix_to_filter)

Get the weekday of a given date:

---@param date string -- e.g., 2021-01-01
---@return string -- the weekday of the given date.
require('dates').get_weekday(date)

Get dates from date to date:

---@param from_date string -- e.g., 2021-01-01
---@param to_date string -- e.g., 2021-01-31
---@return table -- array of suggested date strings
require('dates').get_dates(from_date, to_date)

Example

-- Check if a date is valid
assert(require('dates').is_valid(2024, 8, 31) == true)
assert(require('dates').is_valid(2024, 2, 31) == false)

-- Get dates for a given prefix
assert(require('dates').get("2024-01-0") == {
  "2024-01-01",
  "2024-01-02",
  "2024-01-03",
  "2024-01-04",
  "2024-01-05",
  "2024-01-06",
  "2024-01-07",
  "2024-01-08",
  "2024-01-09",
})

-- Get the weekday of a given date
assert(require('dates').get_weekday("2024-01-01") == "Monday")

-- Get dates from date to date
assert(require('dates').get_dates("2024-01-01", "2024-01-03") == {
  "2024-01-01",
  "2024-01-02",
  "2024-01-03",
})

License

MIT

dates.nvim's People

Contributors

oleksiiluchnikov avatar

Stargazers

 avatar Yuto Tanaka(Work) avatar Yuta Katayama avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.