123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- using NPOI.SS.Formula.Functions;
- using System;
- using System.Collections.Generic;
- using System.Text;
- namespace ProductionLineMonitor.Core.Utils
- {
- public class DateTimeHelper
- {
- public static void GetStartEndTime(DateTime date, out DateTime startTime, out DateTime endTime)
- {
- int year, month, day;
- year = date.Year;
- month = date.Month;
- day = date.Day;
- if (day < 21)
- {
- month -= 1;
- if (month == 0)
- {
- year -= 1;
- month = 12;
- }
- }
- startTime = Convert.ToDateTime($"{year}-{month}-21 08:00:00");
- endTime = startTime.AddMonths(1).AddDays(-1);
- }
- public static List<object> GetDate(DateTime startTime, DateTime endTime)
- {
- List<object> rev = new List<object>();
- for (DateTime dt = startTime; dt <= endTime; dt = dt.AddDays(+1))
- {
- rev.Add(dt.ToString("yyyy-MM-dd"));
- }
- return rev;
- }
- public static List<DateTime> GetDateTime(DateTime startTime, DateTime endTime)
- {
- List<DateTime> rev = new List<DateTime>();
- for (DateTime dt = startTime; dt < endTime; dt = dt.AddDays(+1))
- {
- rev.Add(dt);
- }
- return rev;
- }
- public static List<string> GetDateString(DateTime startTime, DateTime endTime)
- {
- List<string> rev = new List<string>();
- for (DateTime dt = startTime; dt <= endTime; dt = dt.AddDays(+1))
- {
- rev.Add(dt.ToString("yyyy-MM-dd"));
- }
- return rev;
- }
- public static List<object> GetDateShift(DateTime startTime, DateTime endTime)
- {
- List<object> rev = new List<object>();
- for (DateTime dt = startTime; dt <= endTime; dt = dt.AddDays(+1))
- {
- rev.Add(dt.ToString("yyyy-MM-dd 08:00:00"));
- rev.Add(dt.ToString("yyyy-MM-dd 20:00:00"));
- }
- return rev;
- }
- public static List<object> GetDateShiftV1(DateTime startTime, DateTime endTime)
- {
- List<object> rev = new List<object>();
- for (DateTime dt = startTime; dt <= endTime; dt = dt.AddDays(+1))
- {
- rev.Add(dt.ToString("yyyy-MM-dd 白班"));
- rev.Add(dt.ToString("yyyy-MM-dd 夜班"));
- }
- return rev;
- }
- }
- }
|