确定是否日期时间是在给定的日期范围 [英] Determine if DateTime is in a given Date Range
本文介绍了确定是否日期时间是在给定的日期范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Aries March 21 to April 20.
Taurus April 21 to May 20.
Gemini May 21 to June 21.
我需要通过获取用户的出生月份和日期作为输入打印用户的星座。我怎样才能获得日期范围
I need to print the Astrological sign of a user by getting the user's birth month and the date as inputs. How can I get the date range?
EX:3月21日至4月二十日
EX: March 21 to April 20
推荐答案
您实际上并不需要构造一个日期时间范围内解决这个问题。基于每月用一个简单的如果返回的二星级标志之一就足够了每个月声明一个简单的switch语句。
You don't actually need to construct a datetime range to solve this. A simple switch statement based on the month with a simple if statement for each month that returns one of two star signs will suffice.
e.g
switch (month)
{
case 1:
if (day <20) return "Capricorn"; else return "Aquarius";
break;
case 2:
...
这篇关于确定是否日期时间是在给定的日期范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文