Skip to content

Instantly share code, notes, and snippets.

@Ogacha
Created December 25, 2017 08:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ogacha/74aa917a3d314cb29e06594c7f31a5c5 to your computer and use it in GitHub Desktop.
Save Ogacha/74aa917a3d314cb29e06594c7f31a5c5 to your computer and use it in GitHub Desktop.
DateAdd for CommandPrompt
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DateAdd
{
class Program
{
static void Main(string[] args)
{
try
{
var amount = int.Parse(args[1]);
var date =
(args[0].ToLower()[0] == 'y') ? DateTime.Today.AddYears(amount) :
(args[0].ToLower()[0] == 'm') ? DateTime.Today.AddMonths(amount) :
(args[0].ToLower()[0] == 'd') ? DateTime.Today.AddDays(amount) :
DateTime.MinValue;
if (date == DateTime.MinValue) throw new Exception();
Console.WriteLine(date.ToString("yyyy/MM/dd"));
}
catch
{
Console.WriteLine();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment