带日期时间的 py-appscript 过滤器
从 iCal 日历中选择事件时,我尝试使用日期时间属性的日期字段作为过滤器。
以下似乎不起作用(选择当前日期的所有事件):
cal = app("iCal").calendars["myCalender"].get()
cDate = datetime.now()
cEvents = cal.events[its.start_date.day==cDate.day].get()
我得到结果: AttributeError: Unknown property, element or command: 'day'
但是,这有效(用于打印任何事件发生的日子)...
cal = app("iCal").calendars["myCalender"].get()
for cEvent in cal.events.get():
print cEvent.start_date.get().day
I am trying to use the day field of a datetime property as a filter when selecting events from an iCal calendar.
The following doesn't seem to work (to select all events for the current date):
cal = app("iCal").calendars["myCalender"].get()
cDate = datetime.now()
cEvents = cal.events[its.start_date.day==cDate.day].get()
I get the result: AttributeError: Unknown property, element or command: 'day'
However, this works (for printing the days of any events)...
cal = app("iCal").calendars["myCalender"].get()
for cEvent in cal.events.get():
print cEvent.start_date.get().day
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此行
检查
its.start_date.day==cDate.day
并返回False
或True
。作为索引,它会转换为0
和1
并采用cal.events
列表中的前两个元素之一。这是你想要的吗?This line
checks
its.start_date.day==cDate.day
and returnsFalse
orTrue
. As an index, this translates into0
and1
and takes one of the first two elements in thecal.events
list. Is this what you want?