Skip to content

Instantly share code, notes, and snippets.

View davissorenson's full-sized avatar
🌚

Davis Sorenson davissorenson

🌚
View GitHub Profile
@davissorenson
davissorenson / date-fns-rfc-3339-parse.md
Last active February 21, 2021 15:46
Parse RFC 3339 date with date-fns library using Unicode tokens (Unicode Technical Standard #35)

I don't guarantee this to be correct, but it should be a good starting point. Make sure you check the dates you're using first, especially details like whether or not you're using T in between date and time, and whether your format specifies fractions of a second.

import { parse } from "date-fns";

parse("2019-10-12T07:20:50Z", "yyyy-MM-dd'T'HH:mm:ssX", new Date());
// => Date Sat Oct 12 2019 10:20:50 GMT+0300 (Eastern European Summer Time)
@davissorenson
davissorenson / how_to_apply_vscode_onsave_actions_to_all_files.md
Last active May 20, 2021 12:32
How to apply VS Code onSave actions (such as organize imports) to every file in a project

How to apply VS Code onSave actions (such as organize imports) to every file in a project

Rationale

Sometimes you want to apply some VS Code onSave action to every file in the project. There are some extensions that claim to do this, but I haven't found any that work. This is a method I discovered, with some help from Stackoverflow of course.

The basic idea is you want to add a superficial change to the start of each file in order to force VS Code to run the onSave actions.

Method