- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
是否有一个本地的.NET类可以像这样处理时间跨度?我一直找不到。
有没有一个接近的?
Public Class Period
Property FromDate As Date
Property ToDate As Date
Public Sub New(ByVal fromDate As Date, ByVal toDate As Date)
If fromDate > toDate Then
Throw New ArgumentException("fromDate must be less than Or equal toDate")
End If
_FromDate = fromDate
_ToDate = toDate
End Sub
Public Overloads Shared Operator =(ByVal period1 As Period,
ByVal period2 As Period) As Boolean
Return period1.FromDate = period2.FromDate AndAlso
period1.ToDate = period2.ToDate
End Operator
Public Overloads Shared Operator <>(ByVal period1 As Period,
ByVal period2 As Period) As Boolean
Return Not period1 = period2
End Operator
Public Overloads Shared Operator <(ByVal period1 As Period,
ByVal period2 As Period) As Boolean
Return period1.FromDate < period2.FromDate
End Operator
Public Overloads Shared Operator >(ByVal period1 As Period,
ByVal period2 As Period) As Boolean
Return period1.FromDate > period2.FromDate
End Operator
Public Overloads Shared Operator >=(ByVal period1 As Period,
ByVal period2 As Period) As Boolean
Return period1.FromDate >= period2.FromDate
End Operator
Public Overloads Shared Operator <=(ByVal period1 As Period,
ByVal period2 As Period) As Boolean
Return period1.FromDate <= period2.FromDate
End Operator
Public Function Contains(ByVal checkDate As Date) As Boolean
Return checkDate >= Me.FromDate AndAlso
checkDate < Me.ToDate
End Function
Public Overrides Function ToString() As String
Return Format(_FromDate, "MMM-yyyy") & "-" & Format(_ToDate, "MMM-yyyy")
End Function
End Class
Public Class MonthPeriod : Inherits Period
Private _MonthStartDate As Date
Public Sub New(ByVal dateInMonth As Date)
'Everything >= the 1st of the month to < the 1st of the next month
MyBase.New(New Date(dateInMonth.Year, dateInMonth.Month, 1),
New Date(dateInMonth.Year, dateInMonth.Month, 1).AddMonths(1))
_MonthStartDate = New Date(dateInMonth.Year, dateInMonth.Month, 1)
End Sub
Public Overrides Function ToString() As String
Return Format(_MonthStartDate, "MMM-yyyy")
End Function
End Class
最佳答案
简短的回答:我认为没有任何内置的类与之接近。可能最接近的是TimeSpan,但这只是一个相对跨度,没有绝对开始或结束日期的概念。
关于.net - 是否有.NET方式来存储类似于自定义类的时间段?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4169242/
如果我使用以下方法计算 java.time 中 2 个 LocalDate 之间的差异: Period p = Period.between(testDate, today); 然后我得到一个包含年、
我正在开发一个有多种不同费率的预订平台。这些费率由一天中的时间、星期几和一年中的一天决定。以下是所涉及的间隔类型的一些示例: 周一至周五,上午 9 点至下午 5 点 周六和周日,中午 12 点到早上
我有大量数据,包括开始时间、停止时间和值。开始和停止时间因行而异,以 5 分钟为增量。我正在尝试创建一个新的数据框,该数据框具有 5 分钟的间隔以及该间隔在行的开始和停止范围内的所有行的总和。 我有一
我有一个这样的表: --------------------------------------------- |Id | Step | StartedAt
我有一个网络应用程序,用户将在其中输入 2 个日期。一个 StartDate 和一个 EndDate。现在我想编写它,以便在选择 StartDate 和 EndDate 时确定有多少周,然后显示这些周
这看起来并不直截了当。 我正在尝试: @Override public int compare(Period o1, Period o2) { return o1.toStandardDays
我必须为团队发送 session 邀请,这是我的邮件 $ical = 'BEGIN:VCALENDAR PRODID:-//Microsoft Corporation//Outlook 11.0
我有这个 ISO 8601 时间段字符串: P0Y0M0DT3H5M0.000S 并且 PHP7.4 无法用它构造 DateInterval。 format('%h Hours %m Minutes
我想要获取包含一段时间(格式为 HH:MM:SS)的多个单元格的总和。在 LibreOffice Calc 4.0.3.3 中,我复制粘贴了 G14:G21 范围内的时间段,并将单元格格式设置为时间
我有一个表(MySQL),每n秒捕获一次样本。该表有很多列,但重要的是两列:时间戳(TIMESTAMP 类型)和计数(INT 类型)。 我想做的是获取一定时间范围内计数列的总和和平均值。例如,我每 2
我有一个表(MySQL),每n秒捕获一次样本。该表有很多列,但重要的是两列:时间戳(TIMESTAMP 类型)和计数(INT 类型)。 我想做的是获取一定时间范围内计数列的总和和平均值。例如,我每 2
我在一个项目上使用 joda-time (1.6.2),我正在做的其中一件事就是计算预测时间和实际时间之间的差异。这种差异有时是积极的,有时是消极的。虽然适当的方法可能是使用 Duration 而不是
我有一个表 (MySQL),它每 n 秒捕获一次样本。该表有很多列,但最重要的是两列:一个时间戳(TIMESTAMP 类型)和一个计数(INT 类型)。 我想做的是获取计数列在一段时间内的总和和平均值
我想让我的折线图显示过去 3 个月的数据。 GDS 有一个“最后一个季度”的日期范围,但这显示的是 Q1、Q2、Q3 或 Q4。我需要的是过去3个整月(不算当月)的数据。我尝试创建一个计算字段,但事实
我想让我的折线图显示过去 3 个月的数据。 GDS 有一个“最后一个季度”的日期范围,但这显示的是 Q1、Q2、Q3 或 Q4。我需要的是过去3个整月(不算当月)的数据。我尝试创建一个计算字段,但事实
我是一名优秀的程序员,十分优秀!