C#插件、Python两种方式计算日期是当年第几周
借助系统日历计算指定日期是当年第几周
C#插件
private void CalcCurWeek() { DateTime curDate = Convert.ToDateTime(this.View.Model.GetValue("FWeekBDate")); if (curDate != null) { System.Globalization.GregorianCalendar gc = new System.Globalization.GregorianCalendar(); int weekOfYear = gc.GetWeekOfYear(curDate, System.Globalization.CalendarWeekRule.FirstDay, DayOfWeek.Monday); this.View.Model.SetValue("FCurWeek", weekOfYear); } }
Python代码(亲测有效)
import clr clr.AddReference('System') clr.AddReference('System.Globalization') from System import * from System.Globalization import * def DataChanged(e): key = e.Field.Key.upper(); if(key == "FWEEKBDATE"): curDate = this.View.Model.GetValue("FWeekBDate"); if (curDate <> None): gc = GregorianCalendar(); weekOfYear = gc.GetWeekOfYear(curDate, CalendarWeekRule.FirstDay, DayOfWeek.Monday); this.View.Model.SetValue("FCurWeek",weekOfYear);
特别说明:
gc.GetWeekOfYear(curDate, CalendarWeekRule.FirstDay, DayOfWeek.Monday);
这个方法中的 第三个参数 DayOfWeek.Monday 是指定周从星期几开始
C#插件、Python两种方式计算日期是当年第几周
借助系统日历计算指定日期是当年第几周C#插件private void CalcCurWeek() { DateTime curDate = Convert.ToDateTime(thi...
点击下载文档
上一篇:处理客户端快捷方式丢失问题/客户端图标丢失下一篇:二开打开任意单据
本文2024-09-16 17:13:09发表“云星空知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3cloud-14297.html
您需要登录后才可以发表评论, 登录登录 或者 注册
最新文档
热门文章