CSharp examples for System:DateTime Quarter
Round Up To Quarter Hour
using Windows.Globalization.DateTimeFormatting; using System.Threading.Tasks; using System.Text; using System.Linq; using System.Collections.Generic; using System;// www .j av a2s.c o m public class Main{ public static DateTime RoundUpToQuarterHour(this DateTime dateTime) { var newMinute = dateTime.Minute - (dateTime.Minute % 15); if (newMinute != 0) { newMinute += 15; } return new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, dateTime.Hour, 0, 0, 0, dateTime.Kind).AddMinutes(newMinute); } }