No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

LiuNian.cs 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. using Lunar.Util;
  2. // ReSharper disable IdentifierTypo
  3. // ReSharper disable MemberCanBePrivate.Global
  4. // ReSharper disable UnusedAutoPropertyAccessor.Global
  5. namespace Lunar.EightChar
  6. {
  7. /// <summary>
  8. /// 流年
  9. /// </summary>
  10. public class LiuNian
  11. {
  12. /// <summary>
  13. /// 序数,0-9
  14. /// </summary>
  15. public int Index { get; }
  16. /// <summary>
  17. /// 大运
  18. /// </summary>
  19. public DaYun DaYun { get; }
  20. /// <summary>
  21. /// 年
  22. /// </summary>
  23. public int Year { get; }
  24. /// <summary>
  25. /// 年龄
  26. /// </summary>
  27. public int Age { get; }
  28. /// <summary>
  29. /// 阴历
  30. /// </summary>
  31. public Lunar Lunar { get; }
  32. /// <summary>
  33. /// 创建流年
  34. /// </summary>
  35. /// <param name="daYun">大运</param>
  36. /// <param name="index">序数</param>
  37. public LiuNian(DaYun daYun, int index)
  38. {
  39. DaYun = daYun;
  40. Lunar = daYun.Lunar;
  41. Index = index;
  42. Year = daYun.StartYear + index;
  43. Age = daYun.StartAge + index;
  44. }
  45. /// <summary>
  46. /// 干支
  47. /// </summary>
  48. public string GanZhi
  49. {
  50. get
  51. {
  52. int offset = LunarUtil.GetJiaZiIndex(Lunar.JieQiTable["立春"].Lunar.YearInGanZhiExact) + Index;
  53. if (DaYun.Index > 0)
  54. {
  55. offset += DaYun.StartAge - 1;
  56. }
  57. offset %= LunarUtil.JIA_ZI.Length;
  58. return LunarUtil.JIA_ZI[offset];
  59. }
  60. }
  61. /// <summary>
  62. /// 旬
  63. /// </summary>
  64. public string Xun => LunarUtil.GetXun(GanZhi);
  65. /// <summary>
  66. /// 旬空(空亡)
  67. /// </summary>
  68. public string XunKong => LunarUtil.GetXunKong(GanZhi);
  69. /// <summary>
  70. /// 获取流月
  71. /// </summary>
  72. /// <returns>流月</returns>
  73. public LiuYue[] GetLiuYue()
  74. {
  75. const int n = 12;
  76. var l = new LiuYue[n];
  77. for (var i = 0; i < n; i++)
  78. {
  79. l[i] = new LiuYue(this, i);
  80. }
  81. return l;
  82. }
  83. }
  84. }