Skip to content

Instantly share code, notes, and snippets.

Avatar

Matt Johnson-Pint mattjohnsonpint

View GitHub Profile
@mattjohnsonpint
mattjohnsonpint / dateonlybetween.cs
Created May 21, 2021
DateOnly Between methods
View dateonlybetween.cs
public static int DaysBetween(DateOnly startDate, DateOnly endDate)
{
return endDate.DayNumber - startDate.DayNumber;
}
public static (int Months, int Days) MonthsAndDaysBetween(DateOnly startDate, DateOnly endDate)
{
int months = (endDate.Year - startDate.Year) * 12 + endDate.Month - startDate.Month;
DateOnly testDate = startDate.AddMonths(months);
@mattjohnsonpint
mattjohnsonpint / PathModelBinderAttribute.cs
Created Nov 15, 2018
Path Model Binder for ASP.NET Core
View PathModelBinderAttribute.cs
using System;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ModelBinding;
namespace MyNameSpace
{
public class PathModelBinderAttribute : ModelBinderAttribute
{
@mattjohnsonpint
mattjohnsonpint / Program.cs
Created Jan 30, 2017
Just playing with clocks
View Program.cs
using System;
using System.Runtime.InteropServices;
namespace PreciseTimeTest
{
public class Program
{
public static void Main(string[] args)
{
Console.WriteLine("------------------------------------");
@mattjohnsonpint
mattjohnsonpint / Egypt_2016_DST_Cancellation.reg
Last active Jul 7, 2016
Windows Registry Patch for Egypt 2016 Cancellation of DST
View Egypt_2016_DST_Cancellation.reg
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones\Egypt Standard Time]
"TZI"=hex:88,ff,ff,ff,00,00,00,00,c4,ff,ff,ff,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones\Egypt Standard Time\Dynamic DST]
"2016"=hex:88,ff,ff,ff,00,00,00,00,c4,ff,ff,ff,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
"2017"=-
@mattjohnsonpint
mattjohnsonpint / windowsZones-override.xml
Last active Jun 15, 2016
CLDR Overrides for June 2016
View windowsZones-override.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE supplementalData SYSTEM "../../common/dtd/ldmlSupplemental.dtd">
<!--
Copyright © 1991-2013 Unicode, Inc.
CLDR data files are interpreted according to the LDML specification (http://unicode.org/reports/tr35/)
For terms of use, see http://www.unicode.org/copyright.html
-->
<supplementalData>
<version number="$Revision$"/>
@mattjohnsonpint
mattjohnsonpint / railstz.json
Created May 11, 2016
Rails TZ Map in JSON
View railstz.json
{
"International Date Line West":"Pacific/Midway",
"Midway Island":"Pacific/Midway",
"American Samoa":"Pacific/Pago_Pago",
"Hawaii":"Pacific/Honolulu",
"Alaska":"America/Juneau",
"Pacific Time (US & Canada)":"America/Los_Angeles",
"Tijuana":"America/Tijuana",
"Mountain Time (US & Canada)":"America/Denver",
"Arizona":"America/Phoenix",
@mattjohnsonpint
mattjohnsonpint / Program.cs
Created Feb 9, 2016
Testing ISO8601 formatting performance
View Program.cs
using System;
using System.Diagnostics;
using System.Globalization;
namespace DateTimeToIsoStringPerfTests
{
class Program
{
static void Main(string[] args)
{
View moment-2.11.1.md

moment 2.11.1 changelog

Bugfixes:

  • #2881 Revert "Merge pull request #2746 from mbad0la:develop" Sep->Sept
  • #2868 Add format and parse token Y, so it actually works
  • #2865 Use typeof checks for undefined for global variables
  • #2858 Fix Date mocking regression introduced in 2.11.0
  • #2864 Include changelog in npm release
  • #2830 dep: add grunt-cli
  • #2869 Fix months parsing for some locales
@mattjohnsonpint
mattjohnsonpint / Program.cs
Created Nov 7, 2015
Demonstration for StackOverflow question 33579361
View Program.cs
using System;
using System.Globalization;
using NodaTime;
using NodaTime.Text;
namespace ConsoleApplication10
{
class Program
{
static void Main(string[] args)
@mattjohnsonpint
mattjohnsonpint / wordpresstz.html
Created Oct 12, 2015
Wordpress Timezone List
View wordpresstz.html
<select id="timezone_string" name="timezone_string" aria-describedby="timezone-description">
<optgroup label="Africa">
<option value="Africa/Abidjan">Abidjan</option>
<option value="Africa/Accra">Accra</option>
<option value="Africa/Addis_Ababa">Addis Ababa</option>
<option value="Africa/Algiers">Algiers</option>
<option value="Africa/Asmara">Asmara</option>
<option value="Africa/Bamako">Bamako</option>
<option value="Africa/Bangui">Bangui</option>
<option value="Africa/Banjul">Banjul</option>