chinese
date
This commit is contained in:
@@ -10,6 +10,8 @@ using System.Reflection.Emit;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Web;
|
||||
using System.Web.Http;
|
||||
using tyme.solar;
|
||||
|
||||
|
||||
namespace Model
|
||||
{
|
||||
@@ -71,12 +73,12 @@ namespace Model
|
||||
鼠 = 1, 牛 = 2, 虎 = 3, 兔 = 4, 龍 = 5, 蛇 = 6,
|
||||
馬 = 7, 羊 = 8, 猴 = 9, 雞 = 10, 狗 = 11, 豬 = 12
|
||||
}
|
||||
enum heavenlyStems
|
||||
public enum heavenlyStems
|
||||
{
|
||||
甲 = 1, 乙, 丙, 丁, 戊, 己, 庚, 辛, 壬, 癸
|
||||
}
|
||||
|
||||
enum earthlyBranches
|
||||
public enum earthlyBranches
|
||||
{
|
||||
子 = 1, 丑, 寅, 卯, 辰, 巳, 午, 未, 申, 酉, 戌, 亥
|
||||
}
|
||||
@@ -85,28 +87,24 @@ namespace Model
|
||||
public static string chagenSign(DateTime? date)
|
||||
{ //可改公用
|
||||
//生肖
|
||||
if (date == null) return null;
|
||||
|
||||
DateTime d = date.Value;
|
||||
|
||||
// 使用 tyme4net 方法
|
||||
try
|
||||
{
|
||||
if (date != null)
|
||||
{
|
||||
DateTime d = date ?? DateTime.Now;
|
||||
int year = d.Year;
|
||||
int birthpet; //宣告生肖要用的變數
|
||||
var solarDay = SolarDay.FromYmd(d.Year, d.Month, d.Day);
|
||||
var lunarDay = solarDay.GetLunarDay();
|
||||
|
||||
birthpet = year % 12; //西元年除12取餘數
|
||||
birthpet -= 3;
|
||||
//餘數-3
|
||||
if (birthpet <= 0) birthpet += 12;
|
||||
//判斷餘數是否大於0,小於0必須+12
|
||||
return Enum.GetName(typeof(chinese), birthpet);
|
||||
//return ((chinese)birthpet).ToString(); //也可以
|
||||
// 使用正確的 tyme4net API
|
||||
var lunarYear = tyme.lunar.LunarYear.FromYear(lunarDay.Year);
|
||||
return lunarYear.SixtyCycle.EarthBranch.GetZodiac().GetName();
|
||||
}
|
||||
}
|
||||
catch
|
||||
catch (Exception ex)
|
||||
{
|
||||
//return null;
|
||||
return $"生肖計算錯誤: {ex.Message}";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public static string sexagenary(DateTime? date)
|
||||
{
|
||||
|
||||
@@ -8,6 +8,9 @@ using System.Drawing.Imaging;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Web;
|
||||
using tyme.solar;
|
||||
using tyme.lunar;
|
||||
using tyme.sixtycycle;
|
||||
|
||||
/// <summary>
|
||||
/// publicFun 的摘要描述
|
||||
@@ -86,27 +89,35 @@ public class publicFun
|
||||
public static string chagenDate(DateTime? date)//因為欄位值是nullable, 所以把null的處理拉進函數做
|
||||
{ //可改公用
|
||||
//農曆年
|
||||
ChineseLunisolarCalendar chineseDate = new ChineseLunisolarCalendar();
|
||||
if (date == null) return null;
|
||||
|
||||
DateTime d = date.Value;
|
||||
|
||||
// 使用 tyme4net 方法
|
||||
try
|
||||
{
|
||||
if (date != null)
|
||||
var solarDay = SolarDay.FromYmd(d.Year, d.Month, d.Day);
|
||||
var lunarDay = solarDay.GetLunarDay();
|
||||
|
||||
int minYear = lunarDay.Year - 1911;
|
||||
return $"民{minYear}年/{lunarDay.ToString().Substring(2)}";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
DateTime d = date ?? DateTime.Now;
|
||||
// 如果 tyme4net 完全失敗,回退到原本的方法
|
||||
try
|
||||
{
|
||||
ChineseLunisolarCalendar chineseDate = new ChineseLunisolarCalendar();
|
||||
int yy = chineseDate.GetYear(d) - 1911;
|
||||
int mm = chineseDate.GetMonth(d);
|
||||
int dd = chineseDate.GetDayOfMonth(d);
|
||||
string dstr = $"民{yy}年{mm:00}月{dd:00}日";
|
||||
return dstr;
|
||||
}
|
||||
return $"民{yy}年{mm:00}月{dd:00}日";
|
||||
}
|
||||
catch
|
||||
{ //try catch可能會很慢, 已知條件先判斷
|
||||
//return null;
|
||||
{
|
||||
return $"農曆轉換錯誤: {ex.Message}";
|
||||
}
|
||||
}
|
||||
return null;
|
||||
//民國年
|
||||
//System.Globalization.TaiwanCalendar tc = new System.Globalization.TaiwanCalendar();
|
||||
// tc.GetYear(d), tc.GetMonth(d), tc.GetDayOfMonth(d)
|
||||
}
|
||||
|
||||
#region 刪除檔案 for api
|
||||
|
||||
BIN
web/Bin/tyme.dll
Normal file
BIN
web/Bin/tyme.dll
Normal file
Binary file not shown.
@@ -45,7 +45,6 @@
|
||||
{ text: '身分別', value: 'identity_type_desc' },
|
||||
{ text: '性別', value: 'sex' },
|
||||
{ text: '生日', value: 'birthday' },
|
||||
{ text: '生肖/干支', value: 'sign', sortable: false },
|
||||
{ text: '報名記錄', value: 'order_record' },
|
||||
{ text: '', value: 'slot', sortable: false },
|
||||
{ text: '', value: 'slot_btn', sortable: false, align: 'end' },
|
||||
@@ -414,11 +413,15 @@
|
||||
class="elevation-1">
|
||||
|
||||
<template #item.birthday="{ item }" >
|
||||
<div><span class="badge bg-secondary">西元</span> {{ item.birthday|timeString('YYYY/MM/DD') }} </div>
|
||||
<div><span class="badge bg-secondary">農曆</span> {{ item.birthday2 }} </div>
|
||||
</template>
|
||||
<template #item.sign="{ item }" >
|
||||
{{ item.sign }}/{{ item.sexagenary }}
|
||||
<div v-if="item.birthday">
|
||||
<span class="badge bg-secondary">西元</span> {{ item.birthday|timeString('YYYY/MM/DD') }}
|
||||
</div>
|
||||
<div v-if="item.birthday2">
|
||||
<span class="badge bg-secondary">農曆</span> {{ item.birthday2 }} ({{ item.sign }})
|
||||
</div>
|
||||
<div v-if="!item.birthday && !item.birthday2">
|
||||
<span class="badge bg-light text-muted">未填寫</span>
|
||||
</div>
|
||||
</template>
|
||||
<template #item.slot_btn="{ item }">
|
||||
<a :href="'reg.aspx?num='+item.num" class="btn btn-outline-secondary btn-sm"><i class="mdi mdi-pencil-box-outline"></i>修改</a>
|
||||
|
||||
@@ -528,6 +528,13 @@
|
||||
// //this.calculateLunarBirthday();
|
||||
// }
|
||||
//}
|
||||
|
||||
// 提示訊息
|
||||
snackbar: {
|
||||
show: false,
|
||||
message: '',
|
||||
color: 'error'
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
search_show(curr) {
|
||||
@@ -1046,6 +1053,15 @@
|
||||
},
|
||||
fam_save(item) {
|
||||
console.log("fam_save 1:", this.family.edItem);
|
||||
|
||||
// 驗證必填欄位 - 只有姓名必填
|
||||
if (!this.family.edItem.fam_name || this.family.edItem.fam_name.trim() === '') {
|
||||
this.snackbar.message = '請填寫姓名';
|
||||
this.snackbar.color = 'error';
|
||||
this.snackbar.show = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.family.is_tw) {
|
||||
this.family.edItem.city = '';
|
||||
this.family.edItem.area = '';
|
||||
@@ -1956,7 +1972,7 @@
|
||||
<v-form ref="familyForm">
|
||||
<v-text-field
|
||||
v-model="family.edItem.fam_name"
|
||||
label="姓名"
|
||||
label="姓名 * "
|
||||
required
|
||||
></v-text-field>
|
||||
|
||||
@@ -2124,9 +2140,10 @@
|
||||
</v-dialog>
|
||||
<v-snackbar
|
||||
v-model="snackbar.show"
|
||||
timeout="2000"
|
||||
:color="snackbar.color"
|
||||
timeout="3000"
|
||||
>
|
||||
{{ snackbar.text }}
|
||||
{{ snackbar.message }}
|
||||
<template v-slot:action="{ attrs }">
|
||||
<v-btn
|
||||
text
|
||||
|
||||
@@ -105,7 +105,6 @@ public partial class admin_follower_reg : MyWeb.config
|
||||
{
|
||||
Literal1.Text = publicFun.chagenDate(prod.birthday.Value);
|
||||
Literal2.Text = Model.follower.chagenSign(prod.birthday.Value);
|
||||
|
||||
}
|
||||
if (prod.leader.HasValue)
|
||||
{
|
||||
|
||||
@@ -378,7 +378,7 @@
|
||||
start_date: new Date().format("yyyy-MM-dd"),
|
||||
extend_date: '',
|
||||
price: 0,
|
||||
qty: 0,
|
||||
qty: 1,
|
||||
writeBedQty: 0,
|
||||
notBedQty: 0,
|
||||
category: 0,
|
||||
|
||||
Reference in New Issue
Block a user