Skip to content

Instantly share code, notes, and snippets.

@markusjohnsson
Last active August 29, 2015 14:13
Show Gist options
  • Save markusjohnsson/20090ba9cf7c4132cabb to your computer and use it in GitHub Desktop.
Save markusjohnsson/20090ba9cf7c4132cabb to your computer and use it in GitHub Desktop.
Month View Calendar...
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
public class Program
{
public static void Main()
{
var today = DateTime.Today;
var start = new DateTime(today.Year, today.Month, 1);
//for (var s = start
PrintMonth(start);
start.AddMonths(1);
}
public static void PrintMonth(DateTime start)
{
Console.WriteLine(start.ToString("MMMM"));
for (var i = 0; i < (int)start.DayOfWeek; i++)
Console.Write(" \t");
for (
var current = start;
current.Month == start.Month;
current = current.AddDays(1))
{
if (current.DayOfWeek == 0)
Console.WriteLine();
Console.Write(current.Day.ToString().PadLeft(2) + "\t");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment