using Rhea.Common; using System; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Tiger.Business.MESTests { [TestClass()] public class MesTests { [TestMethod()] public void CommonTest() { var date = new DateTime(2021,1,2); var firstDay = new DateTime(date.Year, 1, 1); int daysOffset = firstDay.DayOfWeek.GetValue() > 3 ? (firstDay.DayOfWeek.GetValue() - 7) : 0; int year = date.Year + ((date - firstDay).TotalDays + daysOffset < 0 ? -1 : 0); int week = CultureInfo.CurrentCulture.Calendar.GetWeekOfYear(date, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Sunday); var str = $"{year.ToString().Substring(2, 2)}{week:00}"; ; } } }