using System.Globalization;
public static void Main()
DateTime date = new DateTime(year, 1, 1);;
DateTime firstDayOfQuarter = new DateTime(date.Year, (quarterNumber-1)*3+1,1);
DateTime lastDayOfQuarter = firstDayOfQuarter.AddMonths(3).AddDays(-1);
Console.WriteLine($"firstDayOfQuarter: {firstDayOfQuarter}");
Console.WriteLine($"lastDayOfQuarter: {lastDayOfQuarter}");
DateTime goLiveDate = DateTime.ParseExact("31/01/2025 12:00:00 AM", "dd/MM/yyyy hh:mm:ss tt", CultureInfo.InvariantCulture);
Console.WriteLine($"goLiveDate: {goLiveDate}");
string goLiveDateStr = goLiveDate.ToString("dd/MM/yyyy hh:mm:ss tt");
Console.WriteLine($"goLiveDateStr: {goLiveDateStr}");
string shipByDateTimeStr = "2024-11-20 13:30:00";
bool shipCheck = DateTime.TryParseExact(shipByDateTimeStr, "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out shipByDateTime);
Console.WriteLine($"shipCheck: {shipCheck}");
Console.WriteLine($"shipByDateTime: {shipByDateTime}");
DateTime shipByDate = shipByDateTime.Date;
Console.WriteLine($"shipByDate: {shipByDate}");
TimeSpan shipTimeSpan = shipByDateTime.Subtract(shipByDate);
double shipTime = shipTimeSpan.TotalSeconds;
Console.WriteLine($"shipTime: {shipTime}");
string modifiedDateStr = "2024-11-09";
bool isSuccessC1 = DateTime.TryParseExact(modifiedDateStr, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out modifiedDate);
Console.WriteLine($"isSuccessC1: {isSuccessC1}");
Console.WriteLine($"modifiedDate: {modifiedDate}");
int modifiedTimeInt = 6025;
TimeSpan modifiedTimeSpan = TimeSpan.FromSeconds(modifiedTimeInt);
modifiedDate = modifiedDate.Add(modifiedTimeSpan);
Console.WriteLine($"modifiedDateTime: {modifiedDate}");
bool tryParseExact = DateTime.TryParseExact("2025-02-02 19:35:00", "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out startTime);;
DateTime endTime = DateTime.Now;
TimeSpan span = endTime.Subtract(startTime );
double differenceMinutes = span.TotalMinutes;
Console. WriteLine( $"startTime: {startTime} endTime: {endTime} Difference (minutes): {differenceMinutes}" );
double differenceDays = span.TotalDays;
Console. WriteLine( $"startTime: {startTime} endTime: {endTime} Difference (days): {differenceDays}" );
string settlementTimeStr = "2024-11-09 19:04:13";
bool isSuccess1 = DateTime.TryParseExact(settlementTimeStr, "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out settlementTime);
Console.WriteLine($"isSuccess1: {isSuccess1}");
Console.WriteLine($"settlementTime: {settlementTime}");
string input = "23:59:59";
bool valid = TimeSpan.TryParseExact(input, "hh\\:mm\\:ss", CultureInfo.InvariantCulture, out timeSpan);
Console.WriteLine($"Valid: {valid}");
string t1Str = "18:00:00";
TimeSpan.TryParseExact(t1Str, "hh\\:mm\\:ss", CultureInfo.InvariantCulture, out TimeSpan t1);
Console.WriteLine($"From: {t1}");
string t2Str = "05:00:00";
TimeSpan.TryParseExact(t2Str, "hh\\:mm\\:ss", CultureInfo.InvariantCulture, out TimeSpan t2);
Console.WriteLine($"To: {t2}");
CultureInfo culture = new CultureInfo("en-US");
DateTime timestamp = Convert.ToDateTime("6/13/2024 3:30:00", culture);
Console.WriteLine($"Timestamp: {timestamp}");
DateTime today = DateTime.Today;
DateTime tomorrow = DateTime.Today.AddDays(1);
DateTime fromDateTime = today + t1;
DateTime toDateTime = today + t2;
if (toDateTime < fromDateTime)
toDateTime = tomorrow + t2;
Console.WriteLine($"fromDateTime: {fromDateTime}");
Console.WriteLine($"toDateTime: {toDateTime}");
if (!((timestamp >= fromDateTime) && (timestamp <= toDateTime)))
Console.WriteLine($"{timestamp} tidak masuk range dari {fromDateTime} ke {toDateTime}");
TimeSpan ts4 = TimeSpan.FromMilliseconds(6000);;
Console.WriteLine($"ts4: {ts4}");
Console.WriteLine(timestamp.ToString("ddd"));