Skip to content

Instantly share code, notes, and snippets.

View benhinman's full-sized avatar

Ben Hinman benhinman

View GitHub Profile
@benhinman
benhinman / ParseISODate.js
Created December 4, 2016 09:35
This gist allows you to parse an ISO 8601 subset date in JavaScript. This method could be used in a JSON reviver function to inflate date strings into date objects.
!function () {
var isoDateFormat = /^(\d{4})(?:-(\d{2})(?:-(\d{2})(?:T(\d{2}):(\d{2})(?::(\d{2})(\.\d+)?)?(?:(Z(?=$)|(?:\+|\-)(?=\d{2}:\d{2}))(?:(\d{2}):(\d{2}))?)?)?)?)?$/;
Date.parseIsoDate = function (isoDate, convertToBrowserTimeZone) {
/// <summary>
/// Parses an ISO date.
/// </summary>
/// <param name="isoDate">The ISO date to parse.</param>
/// <param name="convertToBrowserTimeZone" optional="true">Whether or not to convert the date to the browser's time zone (true by default).</param>
/// <returns>A date.</returns>
/// <remarks>
@benhinman
benhinman / PageExtensions.cs
Created December 4, 2016 09:30
This gist allows you to get a master page of a given type from a page. It loops through all parent master pages until the given type has been found.
using System.Web.UI;
namespace Extensions
{
/// <summary>
/// Provides <see cref="Page"/> extensions.
/// </summary>
public static class PageExtensions
{
#region Methods