当前位置: 首页>>代码示例>>C#>>正文


C# GregorianCalendar.GetWeekOfYear方法代码示例

本文整理汇总了C#中System.Globalization.GregorianCalendar.GetWeekOfYear方法的典型用法代码示例。如果您正苦于以下问题:C# GregorianCalendar.GetWeekOfYear方法的具体用法?C# GregorianCalendar.GetWeekOfYear怎么用?C# GregorianCalendar.GetWeekOfYear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Globalization.GregorianCalendar的用法示例。


在下文中一共展示了GregorianCalendar.GetWeekOfYear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: WorkMonth

        public WorkMonth(int year, int month, GermanSpecialDays specialDays, IEnumerable<ShortCut> shortCuts, float hoursPerDay)
        {
            this.year = year;
              this.month = month;
              this.hoursPerDay = hoursPerDay;
              this.Weeks = new ObservableCollection<WorkWeek>();
              this.Days = new ObservableCollection<WorkDay>();
              this.ShortCutStatistic = new ObservableCollection<KeyValuePair<string, ShortCutStatistic>>();
              // TODO which date should i take?
              this.ReloadShortcutStatistic(shortCuts);

              var cal = new GregorianCalendar();
              WorkWeek lastWeek = null;
              for (int day = 1; day <= cal.GetDaysInMonth(year, month); day++) {
            var dt = new DateTime(year, month, day);

            WorkDay wd = new WorkDay(year, month, day, specialDays);
            this.Days.Add(wd);
            var weekOfYear = cal.GetWeekOfYear(dt, CalendarWeekRule.FirstDay, DayOfWeek.Monday);
            if (lastWeek == null || lastWeek.WeekOfYear != weekOfYear) {
              lastWeek = new WorkWeek(this, weekOfYear);
              lastWeek.PropertyChanged += new PropertyChangedEventHandler(this.WeekPropertyChanged);
              this.Weeks.Add(lastWeek);
            }
            lastWeek.AddDay(wd);
              }
        }
开发者ID:vipwolf,项目名称:moni,代码行数:27,代码来源:WorkMonth.cs

示例2: FN_GER_GetWeekOfYear

    public static SqlInt32 FN_GER_GetWeekOfYear(SqlDateTime _date)
    {

        System.Globalization.GregorianCalendar gc = new System.Globalization.GregorianCalendar();


        return _date.IsNull ? SqlInt32.Null : gc.GetWeekOfYear(_date.Value, System.Globalization.CalendarWeekRule.FirstFullWeek, DayOfWeek.Monday);
    }
开发者ID:mvasilva,项目名称:SqlServerExtension,代码行数:8,代码来源:Util.cs

示例3: PosTest3

 public void PosTest3()
 {
     System.Globalization.Calendar kC = new KoreanCalendar();
     System.Globalization.Calendar gC = new GregorianCalendar();
     DateTime dateTime = gC.ToDateTime(2008, 2, 29, 0, 0, 0, 0);
     int expectedValue = gC.GetWeekOfYear(dateTime, new CultureInfo("en-US").DateTimeFormat.CalendarWeekRule, new CultureInfo("en-US").DateTimeFormat.FirstDayOfWeek);
     int actualValue;
     actualValue = kC.GetWeekOfYear(kC.ToDateTime(dateTime.Year + 2333, dateTime.Month, dateTime.Day, 0, 0, 0, 0), new CultureInfo("ko-KR").DateTimeFormat.CalendarWeekRule, new CultureInfo("ko-KR").DateTimeFormat.FirstDayOfWeek);
     Assert.Equal(expectedValue, actualValue);
 }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:10,代码来源:KoreanCalendarGetWeekOfYear.cs

示例4: BindData

        private void BindData()
        {
            int planID = Request.QueryString["planID"] != null ? Int32.Parse(Request.QueryString["planID"].ToString()) : 0;
            if (planID == 0)
            {
                return;
            }
            else
            {
                this.past_plan_content.InnerHtml = "";
                this.current_plan_content.InnerHtml = "";

                ActiveRecord.Model.Plan plan = new ActiveRecord.Model.Plan();
                plan = ActiveRecord.Model.Plan.Find(planID);
                this.current_plan_content.InnerHtml = plan.PlanContent;

                int pastperiod = int.Parse(plan.PlanPeriod) - 1;
                int pastyear = int.Parse(plan.PlanYear);

                if (pastperiod < 0)
                {
                    pastyear = pastyear - 1;

                    if (plan.PlanPeriodType == "年计划")
                    {
                        pastperiod = 12;
                    }
                    else if (plan.PlanPeriodType == "季计划")
                    {
                        pastperiod = 4;
                    }
                    else if (plan.PlanPeriodType == "月计划")
                    {
                        pastperiod = 12;
                    }
                    else if (plan.PlanPeriodType == "周计划")
                    {
                        DateTime end = new DateTime(pastyear, 12, 31);  //该年最后一天

                        System.Globalization.GregorianCalendar gc = new GregorianCalendar();

                        pastperiod = gc.GetWeekOfYear(end, CalendarWeekRule.FirstDay, DayOfWeek.Monday);  //该年星期数

                    }
                }

                ActiveRecord.Model.Plan conclusion = plan.Find(plan.PlanObjectType, plan.PlanPeriodType, pastyear.ToString(), pastperiod.ToString(), plan.PlanCreator);
                if (conclusion != null)
                {
                    this.past_plan_content.InnerHtml = conclusion.PlanConclusion;
                }

            }
        }
开发者ID:blfsir,项目名称:benzoa,代码行数:54,代码来源:PlanView.aspx.cs

示例5: PosTest4

 public void PosTest4()
 {
     System.Globalization.Calendar kC = new KoreanCalendar();
     System.Globalization.Calendar gC = new GregorianCalendar();
     Int64 ticks = _generator.GetInt64(-55) % DateTime.MaxValue.Ticks + 1;
     DateTime dateTime = new DateTime(ticks);
     dateTime = gC.ToDateTime(dateTime.Year, dateTime.Month, dateTime.Day, 0, 0, 0, 0);
     int expectedValue = gC.GetWeekOfYear(dateTime, new CultureInfo("en-US").DateTimeFormat.CalendarWeekRule, new CultureInfo("en-US").DateTimeFormat.FirstDayOfWeek);
     int actualValue;
     actualValue = kC.GetWeekOfYear(kC.ToDateTime(dateTime.Year + 2333, dateTime.Month, dateTime.Day, 0, 0, 0, 0), new CultureInfo("ko-KR").DateTimeFormat.CalendarWeekRule, new CultureInfo("ko-KR").DateTimeFormat.FirstDayOfWeek);
     Assert.Equal(expectedValue, actualValue);
 }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:12,代码来源:KoreanCalendarGetWeekOfYear.cs

示例6: GetWeekOfYear

        /// <summary>
        /// 获取指定日期,在为一年中为第几周
        /// </summary>
        /// <param name="dt">指定时间</param>
        /// <reutrn>返回第几周</reutrn>
        public static int GetWeekOfYear(DateTime dt)
        {
            GregorianCalendar gc = new GregorianCalendar();
            int weekOfYear = gc.GetWeekOfYear(dt, CalendarWeekRule.FirstDay, DayOfWeek.Monday);
            var weekNum = weekOfYear + dt.Year * 100;

            var dayOfWeek = DateTime.Now.DayOfWeek;
            if (dayOfWeek == DayOfWeek.Sunday)
            {
                weekNum += 1;
            }
            return weekNum;
        }
开发者ID:key-value,项目名称:Eagle.First,代码行数:18,代码来源:DateTimeUtility.cs

示例7: addDriverButton_Click

        private void addDriverButton_Click(object sender, EventArgs e)
        {
            MySQL MySQLHandle = new MySQL(GlobalVar.sqlhost, GlobalVar.sqlport, GlobalVar.sqldatabase, GlobalVar.sqlusername, "");
            MySqlConnection sqlReader = MySQLHandle.Connect();
            string stringdrivername = driverName.Text;
            DateTimePicker picker = (DateTimePicker)this.Parent.Parent.Parent.Parent.Controls["logDate"];
            GregorianCalendar gc = new GregorianCalendar();
            int weekno = gc.GetWeekOfYear(picker.Value, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Sunday);
            string stringdate = "" + picker.Value.Year + weekno;
            string insertstring="INSERT INTO `th_ryan_invoices` (`id`, `billed_hours`, `billed_miles`, `cost`, `review`, `driver`,`date`) VALUES (NULL, '', '', '', '', '"+stringdrivername+"','"+stringdate+"');";
            FlowLayoutPanel tabcontrol = (FlowLayoutPanel)this.Parent.Parent.Controls[0];
            WeeklyLog newDriver = new WeeklyLog(stringdrivername,picker.Value);
            tabcontrol.Controls.Add(newDriver);

            FlowLayoutPanel newlayout = new FlowLayoutPanel();
            tabcontrol.Controls.SetChildIndex(newDriver, tabcontrol.Controls.Count - 2);

            tabcontrol = newlayout;
            MySQLHandle.Insert(insertstring, sqlReader);
            MySQLHandle.Disconnect();
            driverName.Text = "";
        }
开发者ID:peterlvilim,项目名称:ShippingManager,代码行数:22,代码来源:addTHRyanDriver.cs

示例8: TimeFilter

        private bool TimeFilter(object obj)
        {
            Cases item = obj as Cases;
            if (item == null)
                return false;

            if (TimeAll.IsChecked == true)
                return true;

            if (Time1Day.IsChecked == true)
                return (DaysSince(item.StartTime) < 1);
            if (Time7Day.IsChecked == true)
                return (DaysSince(item.StartTime) < 7);
            if (Time30Day.IsChecked == true)
                return (DaysSince(item.StartTime) < 30);

            if (TimeThisDay.IsChecked == true)
                return item.StartTime.Year == DateTime.Now.Year && item.StartTime.Month == DateTime.Now.Month && item.StartTime.Day == DateTime.Now.Day;
            if (TimeThisWeek.IsChecked == true)
            {
                System.Globalization.Calendar cal = new System.Globalization.GregorianCalendar();
                return cal.GetWeekOfYear(DateTime.Now, CalendarWeekRule.FirstDay, DayOfWeek.Monday) == cal.GetWeekOfYear(item.StartTime, CalendarWeekRule.FirstDay, DayOfWeek.Monday);
            }
            if (TimeThisMonth.IsChecked == true)
                return item.StartTime.Year == DateTime.Now.Year && item.StartTime.Month == DateTime.Now.Month;



            return false;
        }
开发者ID:abdojobs,项目名称:phonecases-tmp,代码行数:30,代码来源:MainWindow.xaml.cs

示例9: GetWeekOfYear

 private int GetWeekOfYear(DateTime date)
 {
     GregorianCalendar gCal = new GregorianCalendar();
     return gCal.GetWeekOfYear(date, TriggerCalendarWeekRule, TriggerCalendarFirstDayOfWeek);
 }
开发者ID:neumik,项目名称:quartznet,代码行数:5,代码来源:NthIncludedDayTrigger.cs

示例10: GetWeek

        public static Woche GetWeek()
        {
            GregorianCalendar cal = new GregorianCalendar(GregorianCalendarTypes.Localized);
            int c = cal.GetWeekOfYear(DateTime.Now, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday);

            if (c % 2 == 0)
            {
                return Woche.B0Woche;
            }
            else
            {
                return Woche.A0Woche;
            }
        }
开发者ID:famoser,项目名称:Gymoberwil,代码行数:14,代码来源:Helper.cs

示例11: GetWeekOfYear

	public void GetWeekOfYear ()
	{
		GregorianCalendar gc = new GregorianCalendar ();
		Assert.AreEqual (1, gc.GetWeekOfYear (new DateTime (2007, 1, 1), CalendarWeekRule.FirstDay, DayOfWeek.Sunday), "#1");
		//Assert.AreEqual (1, gc.GetWeekOfYear (new DateTime (2000, 1, 1), CalendarWeekRule.FirstDay, DayOfWeek.Sunday), "#2");
		Assert.AreEqual (3, gc.GetWeekOfYear (new DateTime (2000, 1, 10), CalendarWeekRule.FirstDay, DayOfWeek.Sunday), "#2");
		Assert.AreEqual (2, gc.GetWeekOfYear (new DateTime (2000, 1, 10), CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Sunday), "#3");
		Assert.AreEqual (2, gc.GetWeekOfYear (new DateTime (2000, 1, 10), CalendarWeekRule.FirstFullWeek, DayOfWeek.Sunday), "#4");
		Assert.AreEqual (52, gc.GetWeekOfYear (new DateTime (2000, 1, 1), CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Sunday), "#5");
		Assert.AreEqual (52, gc.GetWeekOfYear (new DateTime (2000, 1, 1), CalendarWeekRule.FirstFullWeek, DayOfWeek.Sunday), "#6");
	}
开发者ID:GirlD,项目名称:mono,代码行数:11,代码来源:CalendarTest.cs

示例12: ddlPlanPeriodType_SelectedIndexChanged

        protected void ddlPlanPeriodType_SelectedIndexChanged(object sender, EventArgs e)
        {
            string planPeroidType = ddlPlanPeriodType.SelectedValue;
            string planObjectType = ddlPlanObjectType.SelectedValue;
            DateTime beginDate = DateTime.Now;
            DateTime endDate = DateTime.Now;
            DateTime pastDate = DateTime.Now;
            ActiveRecord.Model.Plan plan = null;

            int currentYear = DateTime.Now.Year;//当前年份
            int pastYear = currentYear - 1;//上一年份
            int nextYear = currentYear + 1;//下一年份

            switch (planPeroidType)
            {
                case "周计划":
                    DisableDropdownList();
                    this.ddlWeek.Visible = true;
                    GregorianCalendar gc = new GregorianCalendar();

                    int weekOfYear=gc.GetWeekOfYear(DateTime.Now, CalendarWeekRule.FirstDay, DayOfWeek.Monday);
                    int nextWeek = gc.GetWeekOfYear(DateTime.Now.AddDays(7), CalendarWeekRule.FirstDay, DayOfWeek.Monday); //weekOfYear + 1;
                    int pastWeek = gc.GetWeekOfYear(DateTime.Now.AddDays(-7), CalendarWeekRule.FirstDay, DayOfWeek.Monday);
                    pastYear = DateTime.Now.AddDays(-7).Year;

                    this.ddlWeek.Items.Clear();
                    this.ddlWeek.Items.Add(new ListItem(weekOfYear.ToString(), weekOfYear.ToString()));
                    if (weekOfYear<nextWeek)
                    {
                        this.ddlWeek.Items.Add(new ListItem(nextWeek.ToString(), nextWeek.ToString()));
                    }

                    DateTime weekStartDate = DateTime.Now;
                    DateTime weekEndDate = DateTime.Now;
                    GetWeek(DateTime.Now.Year, weekOfYear, out  weekStartDate, out  weekEndDate);

                    this.lblTime.Text = "周[" + weekStartDate.ToShortDateString() + " - " + weekEndDate.ToShortDateString() + "]";
                    txtBeginDate.Text = weekStartDate.ToShortDateString();
                    txtEndDate.Text = weekEndDate.ToShortDateString();

                    #region 上周起始日期
                    GetWeek(pastYear, pastWeek, out  weekStartDate, out  weekEndDate);
                    txtPastBeginDate.Text = weekStartDate.ToShortDateString();
                    txtPastEndDate.Text = weekEndDate.ToShortDateString();
                    #endregion

                    // this.lblTime.Text = "周";

                    this.lblPastPlanYear.Text = pastYear.ToString();
                    lblPastPlanPeriod.Text = pastWeek.ToString();
                    this.lblPastPlanPeroidType.Text = "周";

                    this.lblCurrentPlanYear.Text = currentYear.ToString();
                    this.lblCurrentPlanPeroid.Text = weekOfYear.ToString();
                    this.lblCurrentPlanPeroidType.Text = "周";

                    this.lblConclusion.Text = pastYear.ToString() + "年" + pastWeek.ToString() + "周总结";

                    plan = new ActiveRecord.Model.Plan().Find(ddlPlanObjectType.SelectedValue, ddlPlanPeriodType.SelectedValue, lblCurrentPlanYear.Text, lblCurrentPlanPeroid.Text, Server.UrlDecode(Request.Cookies["UserName"].Value));
                    if (plan != null)//本月计划
                    {
                        this.FCKeditor3.Value = plan.PlanContent;
                    }
                    else
                    {
                        this.FCKeditor3.Value = "";
                    }
                    //上月总结
                    plan = new ActiveRecord.Model.Plan().Find(ddlPlanObjectType.SelectedValue, ddlPlanPeriodType.SelectedValue, lblPastPlanYear.Text, int.Parse(lblPastPlanPeriod.Text).ToString(), Server.UrlDecode(Request.Cookies["UserName"].Value));
                    if (plan != null)//上月总结
                    {
                        this.FCKeditor2.Value = plan.PlanConclusion;
                        this.past_plan_content.InnerHtml = plan.PlanContent;//上月计划
                    }
                    else
                    {
                        this.FCKeditor2.Value = "";
                        this.past_plan_content.InnerHtml = "";
                    }

                    break;
                case "月计划":
                    DisableDropdownList();
                    this.ddlMonth.Visible = true;
                   beginDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
                    endDate = new DateTime(beginDate.AddMonths(1).Year, beginDate.AddMonths(1).Month, 1);

                     pastDate = new DateTime(beginDate.AddDays(-1).Year, beginDate.AddDays(-1).Month, 1);

                     txtBeginDate.Text = beginDate.ToShortDateString();
                     txtEndDate.Text = endDate.AddDays(-1).ToShortDateString();
                     txtPastBeginDate.Text = pastDate.ToShortDateString();
                     txtPastEndDate.Text = pastDate.AddMonths(1).AddDays(-1).ToShortDateString();

                     this.lblTime.Text = "月" + "[" + beginDate.ToShortDateString() + " - " + endDate.AddDays(-1).ToShortDateString() + "]";
                    this.ddlMonth.Items.Clear();
                    this.ddlMonth.Items.Add(new ListItem(DateTime.Now.Month.ToString(), DateTime.Now.Month.ToString()));
                    if (DateTime.Now.Month.ToString() != "12")
                    {
                        this.ddlMonth.Items.Add(new ListItem(DateTime.Now.AddMonths(1).Month.ToString(), DateTime.Now.AddMonths(1).Month.ToString()));
//.........这里部分代码省略.........
开发者ID:blfsir,项目名称:benzoa,代码行数:101,代码来源:EditPlan.aspx.cs

示例13: WeeklyLog

        public WeeklyLog(string driverName,DateTime date)
        {
            InitializeComponent();

            MySQL MySQLHandle = new MySQL(GlobalVar.sqlhost, GlobalVar.sqlport, GlobalVar.sqldatabase, GlobalVar.sqlusername, "");
            MySqlConnection sqlReader = MySQLHandle.Connect();

            GregorianCalendar gc = new GregorianCalendar();
            int weekno = gc.GetWeekOfYear(date, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Sunday);
            string stringdate = "" + date.Year + weekno;

            //MySQLHandle.Insert("INSERT INTO `rrs`.`th_ryan_invoies` (`id`, `billed_hours`, `billed_miles`, `cost`, `review`, `driver`) VALUES (NULL, 0, 0, 0, '', '');", sqlReader);
            globalDriverName=driverName;
            driverNameTHRyan.Text = driverName;
            string command="SELECT * FROM `th_ryan_invoices` WHERE `driver` LIKE '" + driverName + "' AND `date` LIKE '" + stringdate + "';";
            MySqlDataReader dataReader = MySQLHandle.Select(command, sqlReader);
            dataReader.Read();
            if (dataReader.HasRows == true)
            {
                string id = dataReader.GetString(0);
                int billedHours = dataReader.GetInt32(1);
                int billedMiles = dataReader.GetInt32(2);
                int cost = dataReader.GetInt32(3);
                string review = dataReader.GetString(4);
                string driver = dataReader.GetString(5);
                billedhoursTextbox.Text = billedHours.ToString();
                billedmilesTextbox.Text = billedMiles.ToString();
                costTextBox.Text = cost.ToString();
                if (review != "")
                {
                    weeklyReviewTextBox.Text = review;
                    reviewCheckbox.Checked = true;
                }
                else
                {
                    reviewCheckbox.Checked = false;
                }
                int diff = date.DayOfWeek - DayOfWeek.Sunday;
                if (diff < 0)
                {
                    diff += 7;
                }
                date = date.AddDays(-1 * diff);
                string date1=date.ToString("yyyy-MM-dd");
                date=date.AddDays(1);
                string date2 = date.ToString("yyyy-MM-dd");
                date = date.AddDays(1);
                string date3 = date.ToString("yyyy-MM-dd");
                date = date.AddDays(1);
                string date4 = date.ToString("yyyy-MM-dd");
                date = date.AddDays(1);
                string date5 = date.ToString("yyyy-MM-dd");
                date = date.AddDays(1);
                string date6 = date.ToString("yyyy-MM-dd");
                date = date.AddDays(1);
                string date7 = date.ToString("yyyy-MM-dd");
                date = date.AddDays(1);
                command = "SELECT * FROM `driver_log` WHERE `driver` LIKE '" + driverName + "' AND (`date` LIKE '" + date1 + "' OR `date` LIKE '" + date2 + "' OR `date` LIKE '" + date3 + "' OR `date` LIKE '" + date4+ "' OR `date` LIKE '" + date5+ "' OR `date` LIKE '" + date6+ "' OR `date` LIKE '" + date7 + "');";
                dataReader.Close();
                dataReader = MySQLHandle.Select(command, sqlReader);
                int hours=0;
                int miles=0;
                for (int i = 0; dataReader.Read(); i++)
                {
                    hours+=dataReader.GetInt32(3);
                    miles+=dataReader.GetInt32(4);
                }
                dataReader.Close();
                loggedhoursTextBox.Text = hours.ToString();
                loggedmilesTextBox.Text = miles.ToString();
            }
            dataReader.Close();
        }
开发者ID:peterlvilim,项目名称:ShippingManager,代码行数:73,代码来源:WeeklyLog.cs

示例14: GetWeek

 private int GetWeek(DateTime date, System.DayOfWeek firstDayOfWeek, bool iso)
 {
     GregorianCalendar cal = new GregorianCalendar();
     CalendarWeekRule weekRule = CalendarWeekRule.FirstFullWeek;
     if (iso)
     {
         firstDayOfWeek = System.DayOfWeek.Monday;
         weekRule = CalendarWeekRule.FirstFourDayWeek;
     }
     return cal.GetWeekOfYear(date, weekRule, firstDayOfWeek);
 }
开发者ID:BclEx,项目名称:GpuStructs,代码行数:11,代码来源:ClockCmd.cs

示例15: GetWeekOfYear

 /// <summary>
 /// 获取某一日期是该年中的第几周
 /// </summary>
 /// <param name="dt">日期</param>
 /// <returns>该日期在该年中的周数</returns>
 public static int GetWeekOfYear(DateTime dt)
 {
     var gc = new GregorianCalendar();
     return gc.GetWeekOfYear(dt, CalendarWeekRule.FirstDay, DayOfWeek.Monday);
 }
开发者ID:Andy-Yin,项目名称:MY_OA_RM,代码行数:10,代码来源:DateTimeHelper.cs


注:本文中的System.Globalization.GregorianCalendar.GetWeekOfYear方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。