Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace Core {
- public static class DateTimeHelper {
- public static DateTime NextMonth(DateTime d) {
- return d.AddMonths(1);
- }
- public static DateTime FirstDayOfMonth(DateTime d) {
- return DateTime.Parse("{0}/1/{1}".FormatString(d.Month,d.Year));
- }
- public static DateTime LastDayOfMonth(DateTime d) {
- return FirstDayOfMonth(d).AddMonths(1).AddDays(-1);
- }
- public static DateTime ConvertFromUnixTimestamp(double timestamp) {
- DateTime origin = new DateTime(1970,1,1,0,0,0,0);
- return origin.AddSeconds(timestamp);
- }
- public static double ConvertToUnixTimestamp(DateTime date) {
- DateTime origin = new DateTime(1970,1,1,0,0,0,0);
- TimeSpan diff = date - origin;
- return Math.Floor(diff.TotalSeconds);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment