问题描述
限时送ChatGPT账号..有没有办法按星期几设置提醒?例如,如果我想在每周五上午 10 点收到提醒.
Is there any way to set a reminder by Day of the week? For example if I want a reminder every Friday at 10am.
完成这项任务的最佳方法是什么?
What is the best way to accomplish this task?
我想我一直在考虑某种时间计算.我希望有一种更简单的方式来做我想做的事情.
I think I've been over thinking some sort of hours calculation. I'm hoping there is a more simplistic way of doing what I'm looking to do.
更新:
我的问题更多是关于如何弄清楚如何为特定日期设置提醒,即使不是今天.假设今天是星期三,我想为每个星期五(或一周中的任何一天)设置提醒...我将如何实现?
My question is more about how to figure out how to set the reminder for a specific day even if it isn't today. So lets say today is Wednesday and I want to set a reminder for every Friday (or ANY day of the week)... How would I accomplish that?
推荐答案
因为提醒需要一个 DateTime,所以它很容易.每个应用程序最多有 50 个提醒:
Since the reminder needs a DateTime its pretty easy. Each application has a max of 50 reminders:
DateTime dateTime = DateTime.Now; //First Friday at 10am
for (int i = 0; i < 50; i++)
{
Reminder reminder = new Reminder("MyReminder")
reminder.Content = "Reminder";
reminder.BeginTime = dateTime.AddDays(i * 7);
ScheduledActionService.Add(reminder);
}
-或者这可能有效-
Reminder reminder = new Reminder("MyReminder")
reminder.Content = "Reminder";
reminder.BeginTime = DateTime.Now; //First Friday at 10am
reminder.Content = "Reminder";
reminder.ExpirationTime = DateTime.Now.AddDays(52 * 7);
reminder.RecurrenceType = RecurrenceInterval.Weekly;
ScheduledActionService.Add(reminder);
编辑
这就是你如何获得下一个星期几
private DateTime GetNextDay(string dayOfWeek)
{
for (int i = 0; i < 7; i++)
{
DateTime currentDateTime = DateTime.Now.AddDays(i);
if (dayOfWeek.Equals(currentDateTime.ToString("dddd")))
return currentDateTime;
}
return DateTime.Now;
}
这篇关于Windows Phone 7 提醒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论