Coder Social home page Coder Social logo

jsynowiec / vscode-insertdatestring Goto Github PK

View Code? Open in Web Editor NEW
63.0 3.0 14.0 200 KB

An extension for Visual Studio Code that provides a configurable command for inserting the current date and time

License: MIT License

TypeScript 77.11% JavaScript 22.89%
visual-studio-code vscode vscode-extension datetime timestamp iso8601 date-formatting date-time

vscode-insertdatestring's Introduction

VSCode extension - Insert Date String

Sponsor Version Ratings Installs License

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

Notice Version 2.0 changed settings namespace from insertdatestring to insertDateString. Please update your userspace and workspace settings.

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 - Inserts current timestamp in milliseconds at the cursor position.
  • 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 Insert DateTime output):
  • Date format string (this affects Insert Date output):
  • Time format string (this affects Insert Time output):
// Date format to be used.
"insertDateString.format": "YYYY-MM-DD hh:mm:ss",
"insertDateString.formatDate": "YYYY-MM-DD",
"insertDateString.formatTime": "hh:mm:ss",

Syntax

  • 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 - 12-hour format of an hour without leading zeros. 1 through 12
  • HH - 12-hour format of an hour with leading zeros. 01 through 12
  • h - 24-hour format of an hour without leading zeros. 0 through 23
  • hh - 24-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 - Milliseconds without leading zeros. 0 through 999
  • SS - Milliseconds with leading zeros. 000 to 999
  • U - Milliseconds since the Unix Epoch (January 1 1970 00:00:00 GMT)
  • u - Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT)
  • A - Ante meridiem and Post meridiem. AM or PM

Time zone designators

  • Z - Time offsets from UTC in the form ±hh[:mm] Examples: +02, +02:30
  • ZZ - Time offsets from UTC in the form ±hh[mm] Examples: +02, +0230
  • ZZZ - Time offsets from UTC in the form ±hh:mm Examples: +02:00, +02:30
  • ZZZZ - 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".
  • w - Day of the week. 1 (for Monday) through 7 (for Sunday)
  • W - Week number of year, first week is the week with 4 January in it
  • o - ISO 8601 year number. This has the same value as YYYY, except that if the ISO week number (W) belongs to the previous or next year, that year is used instead

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:ssZZZ (2013-07-16T20:13:31+01:00)

License

Released under the MIT License.

vscode-insertdatestring's People

Contributors

dependabot[bot] avatar jsynowiec avatar nicosommi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

vscode-insertdatestring's Issues

Manual Installation Error

Manually installing package to ~/.vscode/extensions produces the following error when Insert DateTime is invoked.

command 'insertDateString.insertDateTime' not found

vscode v1.25.1 win64
commit 1f12e67

Can I add custom text??

Thank you your extension, this is very useful!! Thank you!

I wanna insert DateTime + custom text;
for ex)
2021-11-10 12:32:45 by ABCD

so I've tried this in my settings.json.

"insertDateString.format": "YYYY-MM-DD hh:mm:ss by ABCD"
"insertDateString.format": "YYYY-MM-DD hh:mm:ss \b\y \A\B\C\D"
"insertDateString.format": "YYYY-MM-DD hh:mm:ss \b\y \A\B\C\D"

how can I add custom text with datetime?

thank you

Problems with Insert formated date

There are two problems

  1. When you use the command and press ESC, it still outputs date in the editor. It should do that only if I press ENTER

  2. Last command is in vscode is quick to run. When I use "Insert formated date" and edit format, and later rerun last command, it doesn't remember the last format I used so now I either have to change default or edit it each time. It would be good to offer the last format used and this could be tied to file path (so that defaults in config could still have sense). Alternative approach would be to let user defined in config various date formats that could be offered in a list box when running the command and used via hotkeys each.

Shortcut collision on Linux

Hello,

The shortcut CTRL+SHIFT+I in VSCode for Linux is already assigned to 'auto-format' file. It could be nice to make the shortcut for insertdate being editable to avoid that collision 🙂

Insert date with Z difference, format wrong

Hi,
I'm currently in the Philippines with a Mac (German language). My configuration:

OS: macOS 10.12.3
VSCode: 1.9.1
vscode-insertdatestring: 1.2.0

In my settings.json I put:

"insertdatestring.format": "YYYY-MM-DDThh:mm:ssZ"

Executed Insert Datetime

Expected I see

2017-02-10T17:56:00+08:00

but I got this output:

2017-02-10T17:56:00+08

Personal note: thanks for this plugin. Very useful for inserting timestamps into some Markdown files :) 👍

Time Zones

Ability to add/change Time Zones for consistent time stamping between teams and times zones

TZ problem

The extension is off-by-one in showing time on my machine. I live in a Mountain Daylight Savings zone, GMT-06 while you display -0700. My system variable is:

c:\>set TZ
tz=UTC-6

Run it on save instead of manually

Can this be integrated to something like a script that will automatically run it on an onSave event, instead of manually?

I'm new to VSCode and currently using Sublime where I have a python script that replaces a tag you place anywhere in your file, i.e. {@timestamp}, which is replaced by a date stamp or updates it if it exists whenever the file is saved.

Was wondering if this is possible on VSC using your extension.

`TZD` is no longer a valid format placeholder

Extension version 1.1.2.

Tried this format:

{ "insertdatestring.format": "YYYY-MM-DDThh:mm:ssTZD" }

And it turns out: 2017-02-03T13:25:19T+073. (the last D is considered date of month)

I noticed that you changed the date formatter to date-format-lite package, and its time zone designator is Z. So documentation should follow.

Besides, the date formatter also support iso as format settings which output the ISO date time format at GMT. I think for convenience sake, this should be noted down in documentation as well.

Typo in docs

Thank you for the extension! You did a great job, simple and fast.

One thing i notice to be wrong, for the Insert Formated DateTime command when choosing 'u' we get back the seconds format but when we choose 'U' we get the milliseconds format. But in the documentation we have the following:
u - Milliseconds since the Unix Epoch (January 1 1970 00:00:00 GMT)
U - Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT)

which is exactly opposite of what we get from the extension. Now i dont know if the docs are wrong or the extension but they should do the same thing.

Thanks.

Feature Request: recent formats or predefined list in "Insert Formatted DateTime"

Hi there,

Thanks for your great extension.

I have a use case like this, could you please consider it?
My use case is in some file, I need to write YYYY-MM-DD hh:mm:ss and YYYYMMDDhhmmss
But I have to modify the formats each time.

My idea is to add an array of formats in the config, so we can select it in prompt.

Best regards,
Huka

Help: how to make AM/PM lowercase?

right now, when I input "A" into format, it defaults the Ante meridiem (AM) and Post meridiem (PM) to uppercase. Is there anyway to have it as lowercase? I tried using "a" but that does not work for me

This is the format I am currently using: YYYY-MM-DD HH:mmA

insert a newline in Insert Date String

In Settings ... Insert Date String: Format
This works great:

# YYMMDD - #### H:mmA

Can I insert a newline so a Format value like

# YYMMDD \n #### H:mmA

inserts

# YYMMDD
#### H:mmA

I've tried with and without single- and double quotes around newline and carriage return characters. No luck so far. \n, \r, 0xA and 0xD

Thank you for this extension -- long-time listener; first-time caller

Can I call this from a snippet?

I'm a total vs-code n00b, if this is a silly question please tell me.

I'm trying to make a snippet add some code and the current datetime, as I need to keep track of things in a unorthodox way.

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.