Created
December 7, 2017 11:26
-
-
Save DorukUlucay/5bd65dd2f543b02a0ca10ef81c354068 to your computer and use it in GitHub Desktop.
some useful code snippets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace FormUI | |
{ | |
public class Helper | |
{ | |
private static string stampFormat = "{0}{1}{2}T{3}{4}{5}"; | |
public static string TimeStamp() | |
{ | |
var now = DateTime.Now; | |
var result = string.Format(stampFormat, now.Year, Pad("00", now.Month), Pad("00", now.Day), Pad("00", now.Hour), Pad("00", now.Minute), Pad("00", now.Second)); | |
return result; | |
} | |
public static string Pad(string padding, int value) | |
{ | |
return Pad(padding, value.ToString()); | |
} | |
public static string Pad(string padding, string value) | |
{ | |
string result = padding.Substring(0, padding.Length - value.Length) + value; | |
return result; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment