- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我有两个文本框(开始日期、结束日期)。如果开始日期和结束日期值介于任何一个月的 21 号和下个月的 20 号之间,从 startDate 月份开始,我可以做任何其他事情。
例如,
startdate(25/jan/2017) and enddate(20/feb/2017) : 可以做任何逻辑
开始日期(25/jan/2017)和结束日期(21/feb/2017):无法执行逻辑
我为此使用了一些逻辑,
if ((startDate2.Day >= 21 && endDate2.Day >= 21 && emonth == smonth)
|| (startDate2.Day >= 21 && endDate2.Day <= 20 && emonth == smonth + 1)
|| (startDate2.Day <= 20 && endDate2.Day <= 20 && emonth == smonth)
|| (startDate2.Day <= 20 && endDate2.Day >= 21 && emonth == smonth - 1))
{
}
但由于这个 ((startDate2.Day <= 20 && endDate2.Day >= 21 && emonth == smonth - 1))
,它不适用于开始日期(12 月份)和结束日期(1 月份)任何人都可以用正确的逻辑帮助我吗?
最佳答案
可能是因为您希望结束月份
正好比开始月份少一个月
emonth == smonth -1
这意味着如果您将十二月与一月进行比较,它就无法工作
1 == 12-1 => false
不提供任何完整的解决方案,但希望帮助您一点一点地理解;)
关于c# - 我如何在年份的变化中找到下个月和前几个月,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42161332/
今天写程序的时候,突然发现了很早以前写的获取月份天数的函数,经典的switch版,但是获得上月天数的时候,我只是把月份-1了,估计当时太困了吧,再看到有种毛骨悚然的感觉,本来是想再处理一下的,但是一
如标题中所述,Highcharts 显示下个月,而不是我想要显示的正确月份。 $(function () { Highcharts.setOptions({ global:
我有一个“事件”需要安排在每个月的同一天。 假设您将开始日期设置为 5 月 1 日,您应该在 6 月 1 日、7 月 1 日等获得下一个事件。问题在于 31 日的开始日期(下一个可能是 30 或 28
我需要汇总 5 年内接下来 12 个月按“地平线”分组的金额: 假设我们是2015-08-15 SUM amount from 0 to 12 next months (from 2015-08-1
今天写程序的时候,突然发现了很早以前写的获取月份天数的函数,经典的switch版,但是获得上月天数的时候,我只是把月份-1了,估计当时太困了吧,再看到有种毛骨悚然的感觉,本来是想再处理一下的,但是一
我是一名优秀的程序员,十分优秀!