Code Monkey home page Code Monkey logo

vscode-datetimestring-insert's Introduction

UPDATED 2019-12-17 by chorpler

I'm changing the "formatted" part to use standard Moment.js formatting because why not.

Changes:

  • Default format now uses whatever Moment.js uses for an empty string, which is ISO 8601, no fractional seconds
    • It comes out looking like this: 2019-01-01T06:23:44-06:00.
    • In particular, notice there is now a numeric time zone on the end.
  • Changed settings namespace to insertMomentString

VSCode extension - Insert Moment String

A plugin for Visual Studio Code that inserts the current date and/or time according to configured format.

Installation

Open Command Palette by pressing F1, type ext install and then look for Insert Date String extension.

Usage

Following commands are available:

  • Insert DateTime (++I on OS X, Ctrl+Shift+I on Windows and Linux) - Inserts current date and/or time according to configured format (format) at the cursor position.
  • Insert Date - Inserts current date according to configured format (formatDate) at the cursor position.
  • Insert Time - Inserts current time according to configured format (formatTime) at the cursor position.
  • Insert Timestamp String - Inserts current timestamp in string format at the cursor position. Default is ISO 8601, no milliseconds.
    • Default: YYYY-MM-DDTHH:mm:ssZ
    • Sample: 2019-12-18T11:17:32-06:00
  • Insert Timestamp Number - Inserts current timestamp in milliseconds since start of epoch at the cursor position.
    • Sample: 1576689452343
  • Insert Sortable - Inserts sortable date and time according to configured format (formatSortable) at the cursor position.
    • Default: YYYYMMDDhhmmss.SS
    • Sample: 20191218111732.34
  • Insert Readable - Inserts a somewhat more human-readable date and time stamp according to configured format (formatReadable) at the cursor position.
    • Default: YYYY-MM-DD HH:mm:ss
    • Sample: 2019-12-18 11:17:32
  • Insert Formatted DateTime (+++I on OS X, Ctrl+Alt+Shift+I on Windows and Linux) - Prompt user for format and insert formatted date and/or time at the cursor position.

Available settings

  • Date and time format string (this affects output of Insert DateTime and Insert Timestamp String, and the default format for Insert Formatted DateTime):
  • Date format string (this affects Insert Date output):
  • Time format string (this affects Insert Time output):
  • Sortable date and time format string (this affects Insert Sortable output):
  • Readable date and time format string (this affects Insert Readable output):
// Date format to be used.
"insertMomentString.format": "YYYY-MM-DDTHH:mm:ssZ",
"insertMomentString.formatSort": "YYYYMMDDhhmmss.SS",
"insertMomentString.formatReadable": "YYYY-MM-DD HH:mm:ss",
"insertMomentString.formatDate": "YYYY-MM-DD",
"insertMomentString.formatTime": "HH:mm:ss",

Syntax (see MomentJS formatting)

  • Y - A two digit representation of a year without leading zeros. Examples: 99 or 3
  • YY - A two digit representation of a year. Examples: 99 or 03
  • YYYY - A full numeric representation of a year, 4 digits. Examples: 1999 or 2003
  • M - Numeric representation of a month, without leading zeros. 1 through 12
  • MM - Numeric representation of a month, with leading zeros. 01 through 12
  • MMM - A short textual representation of a month, three letters. Jan through Dec
  • MMMM - A full textual representation of a month, such as January or March. January through December
  • D - Day of the month without leading zeros. 1 to 31
  • DD - Day of the month, 2 digits with leading zeros. 01 to 31
  • DDD - A textual representation of a day, three letters. Mon through Sun
  • DDDD - A full textual representation of the day of the week. Sunday through Saturday
  • H - 24-hour format of an hour without leading zeros. 1 through 12
  • HH - 24-hour format of an hour with leading zeros. 01 through 12
  • h - 12-hour format of an hour without leading zeros. 0 through 23
  • hh - 12-hour format of an hour with leading zeros. 00 through 23
  • m - Minutes without leading zeros. 0 through 59
  • mm - Minutes with leading zeros. 00 to 59
  • s - Seconds without leading zeros. 0 through 59
  • ss - Seconds with leading zeros. 00 to 59
  • S - Tenths of a second. 0 to 9
  • SS - Hundredths of a second. 00 to 99
  • SSS - Milliseconds. 000 to 999
  • x - Milliseconds since the Unix Epoch (January 1 1970 00:00:00 GMT)
  • X - Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT)
  • A - Ante meridiem and Post meridiem. AM or PM
  • A - Ante meridiem and Post meridiem, lowercase. am or pm

Time zone designators

  • Z - Time offsets from UTC in the form ±hh:mm. Examples: +02:00, +02:30
  • ZZ - Time offsets from UTC in the form ±hhmm. Examples: +0200, +0230

ISO-8601

  • iso - Simplified extended ISO format (ISO 8601) without miliseconds. The timezone is always zero UTC offset, as denoted by the suffix "Z".
  • e - Day of the week for locale. 0 (for Monday) through 6 (for Sunday)
  • E - ISO Day of the week. 1 (for Monday) through 7 (for Sunday)

Examples

  • UTC date and time: iso (2013-07-16T20:13:31Z)
  • Year and month: YYYY-MM (2013-07)
  • Complete date: YYYY-MM-DD (2013-07-16)
  • Complete date plus hours, minutes, seconds and difference to GMT: YYYY-MM-DDTHH:mm:ssZ (2013-07-16T20:13:31+01:00)

License

Released under the MIT License.

vscode-datetimestring-insert's People

Contributors

jsynowiec avatar nicosommi avatar chorpler avatar

Watchers

James Cloos 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.