您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

711 行
24KB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace HealthMonitor.Common
  7. {
  8. public class DateTimeUtil
  9. {
  10. /// <summary>
  11. /// 毫秒时间戳转本地时间
  12. /// </summary>
  13. /// <param name="milliseconds"></param>
  14. /// <returns></returns>
  15. public static DateTime GetDateTimeFromUnixTimeMilliseconds(long milliseconds)
  16. {
  17. DateTimeOffset dt0 = DateTimeOffset.FromUnixTimeMilliseconds(milliseconds);
  18. //默认为UTC时间:{2019/11/14 1:53:26}
  19. //DateTime dt1 = dt0.DateTime;
  20. //转为本地时区:{2019/11/14 9:53:26}
  21. DateTime dt2 = dt0.LocalDateTime;
  22. return dt2;
  23. }
  24. /// <summary>
  25. /// 判断给定的日期时间字符串是否符合相应的格式
  26. /// </summary>
  27. /// <param name="strDate">日期时间字符串</param>
  28. /// <returns>是否符合格式</returns>
  29. public static bool IsDateTime(string strDate)
  30. {
  31. if (strDate.Length != 19)
  32. return false;
  33. try
  34. {
  35. DateTime dt = DateTime.Parse(strDate);
  36. return true;
  37. }
  38. catch
  39. {
  40. return false;
  41. }
  42. }
  43. /// <summary>
  44. /// 得到当前月的第一天
  45. /// </summary>
  46. /// <returns>当前月的第一天</returns>
  47. public static string ThisMonthFirstDate
  48. {
  49. get
  50. {
  51. DateTime dt = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1);
  52. return dt.ToString("yyyy-MM-dd HH:mm:ss");
  53. }
  54. }
  55. /// <summary>
  56. /// 得到当前月的最后一天
  57. /// </summary>
  58. /// <returns>当前月的最后一天</returns>
  59. public static string ThisMonthLastDate
  60. {
  61. get
  62. {
  63. DateTime dt = new DateTime(DateTime.Today.Year, DateTime.Today.Month + 1, 1);
  64. dt = dt.AddDays(-1);
  65. return dt.ToString("yyyy-MM-dd HH:mm:ss");
  66. }
  67. }
  68. /// <summary>
  69. /// 指定日期的该月第一天
  70. /// </summary>
  71. /// <param name="sThisDate">指定的日期</param>
  72. /// <returns>该月第一天</returns>
  73. public static string MonthFirstDate(string sThisDate)
  74. {
  75. int nYear = Year(sThisDate);
  76. int nMonth = Month(sThisDate);
  77. int nDay = 1;
  78. return EncodeDate(nYear, nMonth, nDay) + " 00:00:00";
  79. }
  80. /// <summary>
  81. /// 指定日期的该月最后一天
  82. /// </summary>
  83. /// <param name="sThisDate">指定的日期</param>
  84. /// <returns>该月最后一天</returns>
  85. public static string MonthLastDate(string sThisDate)
  86. {
  87. int nYear = Year(sThisDate);
  88. int nMonth = Month(sThisDate);
  89. nMonth++;
  90. if (nMonth == 13)
  91. {
  92. nYear++;
  93. nMonth = 1;
  94. }
  95. DateTime dt = new DateTime(nYear, nMonth, 1);
  96. dt = dt.AddDays(-1);
  97. return dt.ToString("yyyy-MM-dd HH:mm:ss");
  98. }
  99. /// <summary>
  100. /// 转换字符串类型的时间至日期时间类型
  101. /// </summary>
  102. /// <param name="strDateTime">时间字符串</param>
  103. /// <returns>日期时间类型的值</returns>
  104. /// <remarks>如果格式不正确,则返回当前的时间</remarks>
  105. public static DateTime ToDateTime(string strDateTime)
  106. {
  107. try
  108. {
  109. return DateTime.Parse(strDateTime);
  110. }
  111. catch
  112. {
  113. return DateTime.Now;
  114. }
  115. }
  116. /// <summary>
  117. /// 转换时间类型的字符串至日期时间类型
  118. /// </summary>
  119. /// <param name="strTime">时间字符串</param>
  120. /// <returns>时间值</returns>
  121. /// <remarks>如果格式不正确,则返回的是"00:00:00"的时间值</remarks>
  122. public static DateTime ToTime(string strTime)
  123. {
  124. try
  125. {
  126. return DateTime.Parse(strTime);
  127. }
  128. catch
  129. {
  130. return DateTime.Parse("00:00:00");
  131. }
  132. }
  133. /// <summary>
  134. /// 将时间值转换至时间字符串
  135. /// </summary>
  136. /// <param name="time">时间值</param>
  137. /// <returns>时间字符串</returns>
  138. public static string ToTimeStr(DateTime time)
  139. {
  140. return time.ToString("HH:mm:ss");
  141. }
  142. /// <summary>
  143. /// 将对象转换为指定格式的字符串
  144. /// </summary>
  145. /// <param name="time">待转换的对象</param>
  146. /// <param name="sFormat">指定的字符串格式</param>
  147. /// <returns>转换后的字符串</returns>
  148. /// <remarks>如果为空值,或非日期时间对象,则返回""</remarks>
  149. public static string ToTimeStr(object time, string sFormat)
  150. {
  151. if (time == null || time == DBNull.Value)
  152. return "";
  153. else
  154. {
  155. try
  156. {
  157. return ((DateTime)time).ToString(sFormat);
  158. }
  159. catch
  160. {
  161. return "";
  162. }
  163. }
  164. }
  165. /// <summary>
  166. /// 将对象转换为字符串,格式为"HH:mm:ss"
  167. /// </summary>
  168. /// <param name="time">待转换的对象</param>
  169. /// <returns>转换后的字符串</returns>
  170. public static string ToTimeStr(object time)
  171. {
  172. return ToTimeStr(time, "HH:mm:ss");
  173. }
  174. /// <summary>
  175. /// 从秒数转换为时间字符串
  176. /// </summary>
  177. /// <param name="Second">秒数</param>
  178. /// <returns>时间字符串</returns>
  179. public static string ToTimeStrFromSecond(int Second)
  180. {
  181. //=========== 1. 得到小时、分钟和秒数 ===========
  182. string sTimeStr = "";
  183. int NewSecond = 0;
  184. int hour = Math.DivRem(Second, 3600, out NewSecond); //小时
  185. Second = NewSecond;
  186. NewSecond = 0;
  187. int minute = Math.DivRem(Second, 60, out NewSecond); //分钟
  188. //============ 2. 得到返回的字符串 ============
  189. if (hour < 10)
  190. sTimeStr = sTimeStr + "0" + hour.ToString() + ":";
  191. else
  192. sTimeStr = sTimeStr + hour.ToString() + ":";
  193. if (minute < 10)
  194. sTimeStr = sTimeStr + "0" + minute.ToString() + ":";
  195. else
  196. sTimeStr = sTimeStr + minute.ToString() + ":";
  197. if (NewSecond < 10)
  198. sTimeStr = sTimeStr + "0" + NewSecond.ToString();
  199. else
  200. sTimeStr = sTimeStr + NewSecond.ToString();
  201. return sTimeStr;
  202. }
  203. /// <summary>
  204. /// 将时间字符串转换为秒数
  205. /// </summary>
  206. /// <param name="timeStr">时间字符串</param>
  207. /// <returns>转换后的秒数</returns>
  208. public static int ToSecondsFromTimeStr(string timeStr)
  209. {
  210. DateTime dt = ToTime(timeStr);
  211. return dt.Hour * 3600 + dt.Minute * 60 + dt.Second;
  212. }
  213. /// <summary>
  214. /// 将日期时间值转换为日期字符串
  215. /// </summary>
  216. /// <param name="dt">日期时间值</param>
  217. /// <returns>日期字符串</returns>
  218. public static string ToDateStr(DateTime dt)
  219. {
  220. return dt.ToString("yyyy-MM-dd");
  221. }
  222. /// <summary>
  223. /// 将对象转换为日期字符串
  224. /// </summary>
  225. /// <param name="dt">对象</param>
  226. /// <param name="defaultStr">缺省字符串</param>
  227. /// <returns>转换后的字符串。如果为空值,则按缺省值返回</returns>
  228. public static string ToDateStr(object dt, string defaultStr)
  229. {
  230. if (dt == null || dt is System.DBNull)
  231. return defaultStr;
  232. else
  233. return ((DateTime)dt).ToString("yyyy-MM-dd");
  234. }
  235. /// <summary>
  236. /// 将对象转换为日期字符串
  237. /// </summary>
  238. /// <param name="dt">对象</param>
  239. /// <returns>转换后的字符串。如果转换不成功,则返回""</returns>
  240. public static string ToDateStr(object dt)
  241. {
  242. return ToDateStr(dt, "");
  243. }
  244. /// <summary>
  245. /// 将日期时间值转换为字符串
  246. /// </summary>
  247. /// <param name="dt">日期时间值</param>
  248. /// <returns>字符串(len=19)</returns>
  249. public static string ToDateTimeStr(DateTime dt)
  250. {
  251. return dt.ToString("yyyy-MM-dd HH:mm:ss");
  252. }
  253. public static string ToDateTimeStrWithMilliSeconds(DateTime dt)
  254. {
  255. int nMilliSeconds = dt.Millisecond;
  256. return dt.ToString("yyyy-MM-dd HH:mm:ss") + "." + nMilliSeconds.ToString("000");
  257. }
  258. /// <summary>
  259. /// 将对象转换为日期时间字符串
  260. /// </summary>
  261. /// <param name="dt">对象</param>
  262. /// <param name="defaultStr">转换不成功时所取的缺省字符串</param>
  263. /// <returns>转换后的日期时间字符串(len=19)</returns>
  264. public static string ToDateTimeStr(object dt, string defaultStr)
  265. {
  266. return ToDateTimeStr(dt, defaultStr, "yyyy-MM-dd HH:mm:ss");
  267. }
  268. /// <summary>
  269. /// 将对象转换为日期时间字符串
  270. /// </summary>
  271. /// <param name="dt">对象</param>
  272. /// <returns>转换后的日期时间字符串(len=19)</returns>
  273. /// <remarks>如果转换不成功,则返回""</remarks>
  274. public static string ToDateTimeStr(object dt)
  275. {
  276. return ToDateTimeStr(dt, "", "yyyy-MM-dd HH:mm:ss");
  277. }
  278. /// <summary>
  279. /// 将对象转换为指定格式的日期时间字符串
  280. /// </summary>
  281. /// <param name="dt">对象</param>
  282. /// <param name="defaultStr">缺省字符串</param>
  283. /// <param name="sFormat">格式</param>
  284. /// <returns>转换后的字符串</returns>
  285. public static string ToDateTimeStr(object dt, string defaultStr, string sFormat)
  286. {
  287. if (dt == null || dt is System.DBNull)
  288. return defaultStr;
  289. else
  290. return ((DateTime)dt).ToString(sFormat);
  291. }
  292. /// <summary>
  293. /// 获取当前的时间
  294. /// </summary>
  295. public static string Now
  296. {
  297. get
  298. {
  299. return DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  300. }
  301. }
  302. /// <summary>
  303. /// 带毫秒部分的当前时间,示例为2003.07.22 10:02:52.136
  304. /// </summary>
  305. public static string NowWithMilliSeconds
  306. {
  307. get
  308. {
  309. DateTime dtNow = DateTime.Now;
  310. int nMilliSeconds = dtNow.Millisecond;
  311. return dtNow.ToString("yyyy-MM-dd HH:mm:ss") + "." + nMilliSeconds.ToString("000");
  312. }
  313. }
  314. /// <summary>
  315. /// 获取当前的时间
  316. /// </summary>
  317. public static string Today
  318. {
  319. get
  320. {
  321. return DateTime.Today.ToString("yyyy-MM-dd HH:mm:ss");
  322. }
  323. }
  324. /// <summary>
  325. /// 获取日期的年份
  326. /// </summary>
  327. /// <param name="dtString">日期时间串</param>
  328. /// <returns>年份</returns>
  329. public static int Year(string dtString)
  330. {
  331. int nYear;
  332. nYear = Convert.ToInt32(dtString.Substring(0, 4));
  333. return nYear;
  334. }
  335. /// <summary>
  336. /// 获取日期的月份
  337. /// </summary>
  338. /// <param name="dtString">日期时间串</param>
  339. /// <returns>月份</returns>
  340. public static int Month(string dtString)
  341. {
  342. int nMonth;
  343. nMonth = Convert.ToInt32(dtString.Substring(5, 2));
  344. return nMonth;
  345. }
  346. /// <summary>
  347. /// 获取日期中该月的第几天
  348. /// </summary>
  349. /// <param name="dtString">日期时间串</param>
  350. /// <returns>该月的第几天</returns>
  351. public static int Day(string dtString)
  352. {
  353. int nDay;
  354. nDay = Convert.ToInt32(dtString.Substring(8, 2));
  355. return nDay;
  356. }
  357. /// <summary>
  358. /// 获取日期中的小时部分
  359. /// </summary>
  360. /// <param name="dtString">日期时间串</param>
  361. /// <returns>小时部分</returns>
  362. public static int Hour(string dtString)
  363. {
  364. int nHour;
  365. if (dtString.Length != 19 && dtString.Length != 23)
  366. return 0;
  367. nHour = Convert.ToInt32(dtString.Substring(11, 2));
  368. return nHour;
  369. }
  370. /// <summary>
  371. /// 获取日期中的分钟部分
  372. /// </summary>
  373. /// <param name="dtString">日期时间串</param>
  374. /// <returns>分钟部分</returns>
  375. public static int Minute(string dtString)
  376. {
  377. int nMinute;
  378. if (dtString.Length != 19 && dtString.Length != 23)
  379. return 0;
  380. nMinute = Convert.ToInt32(dtString.Substring(14, 2));
  381. return nMinute;
  382. }
  383. /// <summary>
  384. /// 获取日期中的秒部分
  385. /// </summary>
  386. /// <param name="dtString">日期时间串</param>
  387. /// <returns>秒部分</returns>
  388. public static int Second(string dtString)
  389. {
  390. int nSecond;
  391. if (dtString.Length != 19 && dtString.Length != 23)
  392. return 0;
  393. nSecond = Convert.ToInt32(dtString.Substring(17, 2));
  394. return nSecond;
  395. }
  396. /// <summary>
  397. /// 获取表示的日期是星期几
  398. /// </summary>
  399. /// <param name="dtString">日期时间串</param>
  400. /// <returns>星期几</returns>
  401. /// <remarks>返回值从0至6;星期日为0,星期六为6</remarks>
  402. public static int DayOfWeek(string dtString)
  403. {
  404. DateTime dt = DateTime.Parse(dtString);
  405. return (int)dt.DayOfWeek;
  406. }
  407. /// <summary>
  408. /// 获取表示的日期是一年中的第几天
  409. /// </summary>
  410. /// <param name="dtString">日期时间串</param>
  411. /// <returns>一年中的第几天</returns>
  412. public static int DayOfYear(string dtString)
  413. {
  414. DateTime dt = DateTime.Parse(dtString);
  415. return dt.DayOfYear;
  416. }
  417. /// <summary>
  418. /// 将指定的月份数加到日期值上
  419. /// </summary>
  420. /// <param name="dtString">原来的日期</param>
  421. /// <param name="nOffset">指定的月份数</param>
  422. /// <returns>得到的日期</returns>
  423. public static string AddMonths(string dtString, int nOffset)
  424. {
  425. DateTime dt = DateTime.Parse(dtString);
  426. DateTime dtRes = dt.AddMonths(nOffset);
  427. return dtRes.ToString("yyyy-MM-dd HH:mm:ss");
  428. }
  429. /// <summary>
  430. /// 将指定的天数加到日期值上
  431. /// </summary>
  432. /// <param name="dtString">原来的日期</param>
  433. /// <param name="offset">指定的天数</param>
  434. /// <returns>得到的日期</returns>
  435. /// <remarks>天数可以为负数</remarks>
  436. public static string AddDays(string dtString, int offset)
  437. {
  438. DateTime dt = DateTime.Parse(dtString);
  439. DateTime dtRes = dt.AddDays(offset);
  440. return dtRes.ToString("yyyy-MM-dd HH:mm:ss");
  441. }
  442. /// <summary>
  443. /// 将指定的秒数加到日期值上
  444. /// </summary>
  445. /// <param name="dtString">原来的日期时间</param>
  446. /// <param name="offset">指定的秒数</param>
  447. /// <returns>得到的日期时间</returns>
  448. /// <remarks>秒数可以为负数</remarks>
  449. public static string AddSeconds(string dtString, int offset)
  450. {
  451. DateTime dt = DateTime.Parse(dtString);
  452. DateTime dtRes = dt.AddSeconds(offset);
  453. return dtRes.ToString("yyyy-MM-dd HH:mm:ss");
  454. }
  455. public static string AddMilliSeconds(string dtString, int offset)
  456. {
  457. DateTime dt = DateTime.Parse(dtString);
  458. DateTime dtRes = dt.AddMilliseconds(offset);
  459. int nMilliSeconds = dtRes.Millisecond;
  460. return dtRes.ToString("yyyy-MM-dd HH:mm:ss") + "." + nMilliSeconds.ToString("000");
  461. }
  462. public static string AddMilliSeconds(string dtString, double offset)
  463. {
  464. DateTime dt = DateTime.Parse(dtString);
  465. DateTime dtRes = dt.AddMilliseconds(offset);
  466. int nMilliSeconds = dtRes.Millisecond;
  467. return dtRes.ToString("yyyy-MM-dd HH:mm:ss") + "." + nMilliSeconds.ToString("000");
  468. }
  469. /// <summary>
  470. /// 得到两个日期时间之间相差的天数
  471. /// </summary>
  472. /// <param name="dtFromString">起始日期</param>
  473. /// <param name="dtToString">终止日期</param>
  474. /// <returns>相差的天数</returns>
  475. /// <remarks>
  476. /// 不判断时间的情况。只判断日期是否切换,即使时间相差仅数分钟,
  477. /// 只要切换了日期,也计算相差的天数。例如,2005-05-05 23:58:58和
  478. /// 2005-05-06 00:02:03之间所差的天数也是1。
  479. /// </remarks>
  480. public static int DaysAfter(string dtFromString, string dtToString)
  481. {
  482. DateTime dtFrom = DateTime.Parse(dtFromString).Date;
  483. DateTime dtTo = DateTime.Parse(dtToString).Date;
  484. TimeSpan timeSpan = dtTo - dtFrom;
  485. return (int)timeSpan.TotalDays;
  486. }
  487. /// <summary>
  488. /// 得到两个日期时间之间相差的秒数
  489. /// </summary>
  490. /// <param name="dtFromString">起始日期时间</param>
  491. /// <param name="dtToString">终止日期时间</param>
  492. /// <returns>相差的秒数</returns>
  493. public static int SecondsAfter(string dtFromString, string dtToString)
  494. {
  495. DateTime dtFrom = DateTime.Parse(dtFromString);
  496. DateTime dtTo = DateTime.Parse(dtToString);
  497. TimeSpan timeSpan = dtTo - dtFrom;
  498. return (int)timeSpan.TotalSeconds;
  499. }
  500. /// <summary>
  501. /// 得到两个日期时间之间相差的毫秒数
  502. /// </summary>
  503. /// <param name="dtFromString">起始日期时间</param>
  504. /// <param name="dtToString">终止日期时间</param>
  505. /// <returns>相差的毫秒数</returns>
  506. public static int MilliSecondsAfter(string dtFromString, string dtToString)
  507. {
  508. DateTime dtFrom = DateTime.Parse(dtFromString);
  509. DateTime dtTo = DateTime.Parse(dtToString);
  510. TimeSpan timeSpan = dtTo - dtFrom;
  511. return (int)timeSpan.TotalMilliseconds;
  512. }
  513. /// <summary>
  514. /// 通过时、分、秒得到时间串
  515. /// </summary>
  516. /// <param name="nHour">小时</param>
  517. /// <param name="nMinute">分钟</param>
  518. /// <param name="nSecond">秒</param>
  519. /// <returns>时间部分</returns>
  520. public static string EncodeTime(int nHour, int nMinute, int nSecond)
  521. {
  522. string sResult = nHour.ToString("00") + ":" + nMinute.ToString("00")
  523. + ":" + nSecond.ToString("00");
  524. return sResult;
  525. }
  526. /// <summary>
  527. /// 通过年、月、日得到日期部分
  528. /// </summary>
  529. /// <param name="nYear">年份</param>
  530. /// <param name="nMonth">月份</param>
  531. /// <param name="nDay">日</param>
  532. /// <returns>日期部分</returns>
  533. public static string EncodeDate(int nYear, int nMonth, int nDay)
  534. {
  535. string sResult = nYear.ToString("0000") + "-" + nMonth.ToString("00")
  536. + "-" + nDay.ToString("00");
  537. return sResult;
  538. }
  539. /// <summary>
  540. /// 得到日期部分
  541. /// </summary>
  542. /// <param name="sDatetime">日期时间</param>
  543. /// <returns>日期部分</returns>
  544. public static string GetDatePart(string sDatetime)
  545. {
  546. if (sDatetime.Length < 10)
  547. return "";
  548. return sDatetime.Substring(0, 10);
  549. }
  550. /// <summary>
  551. /// 得到时间部分
  552. /// </summary>
  553. /// <param name="sDatetime">日期时间</param>
  554. /// <returns>时间部分</returns>
  555. public static string GetTimePart(string sDatetime)
  556. {
  557. if (sDatetime.Length == 19)
  558. return sDatetime.Substring(11, 8);
  559. else
  560. return "00:00:00";
  561. }
  562. /// <summary>
  563. /// 得到一天的起始时间
  564. /// </summary>
  565. /// <param name="sDate">日期</param>
  566. /// <returns>起始时间</returns>
  567. public static string BeginTimeOfDay(string sDate)
  568. {
  569. if (sDate.Length > 10)
  570. sDate = sDate.Substring(0, 10);
  571. return sDate + " 00:00:00";
  572. }
  573. /// <summary>
  574. /// 得到一天的结束时间
  575. /// </summary>
  576. /// <param name="sDate">日期</param>
  577. /// <returns>结束时间</returns>
  578. public static string EndTimeOfDay(string sDate)
  579. {
  580. if (sDate.Length > 10)
  581. sDate = sDate.Substring(0, 10);
  582. return sDate + " 23:59:59.999";
  583. }
  584. /// <summary>
  585. /// 由19位的日期时间转到14位的日期时间
  586. /// </summary>
  587. /// <param name="sDT">19位的日期时间</param>
  588. /// <returns>14位的日期时间</returns>
  589. public static string ToDateTime14Str(string sDT)
  590. {
  591. if (sDT == "")
  592. return "";
  593. if (sDT.Length != 19)
  594. throw new Exception("DateTimeUtil.ToDateTime14Str() error : 参数不是19位");
  595. string sRet = sDT.Replace(":", "").Replace("-", "").Replace(" ", "");
  596. if (sRet.Length != 14)
  597. throw new Exception("DateTimeUtil.ToDateTime14Str() error : 返回值不是14位");
  598. return sRet;
  599. }
  600. /// <summary>
  601. /// 由14位的日期时间转到19位的日期时间
  602. /// </summary>
  603. /// <param name="sDT14">14位的日期时间</param>
  604. /// <returns>19位的日期时间</returns>
  605. public static string FromDateTime14Str(string sDT14)
  606. {
  607. if (sDT14 == "")
  608. return "";
  609. if (sDT14.Length != 14)
  610. throw new Exception("DateTimeUtil.FromDateTime14Str() error : 参数不是14位");
  611. string sRet = sDT14.Substring(0, 4) + "-" + sDT14.Substring(4, 2)
  612. + "-" + sDT14.Substring(6, 2)
  613. + " " + sDT14.Substring(8, 2) + ":" + sDT14.Substring(10, 2)
  614. + ":" + sDT14.Substring(12, 2);
  615. return sRet;
  616. }
  617. ///// <summary>
  618. ///// 是否为日期型字符串
  619. ///// </summary>
  620. ///// <param name="StrSource">日期字符串(2008-05-08)</param>
  621. ///// <returns></returns>
  622. //public static bool IsDate(string StrSource)
  623. //{
  624. // return Regex.IsMatch(StrSource, @"^((((1[6-9]|[2-9]\d)\d{2})-(0?[13578]|1[02])-(0?[1-9]|[12]\d|3[01]))|(((1[6-9]|[2-9]\d)\d{2})-(0?[13456789]|1[012])-(0?[1-9]|[12]\d|30))|(((1[6-9]|[2-9]\d)\d{2})-0?2-(0?[1-9]|1\d|2[0-9]))|(((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))-0?2-29-))$");
  625. //}
  626. }
  627. }