[英]Add one day to a date and save it as a new variable in Smalltalk
so here is the problem.所以这就是问题所在。 I want to take a date from lastDate and put it to nextDate , but also add one day to the variable nextDate .我想从lastDate中获取一个日期并将其放入nextDate ,但还要在变量nextDate中添加一天。 Anyone know how to do that?有谁知道该怎么做?
| lastDate nextDate |
lastDate := Date
newDay: 10
monthNumber: 5
year: 2019.
nextDate := lastDate.
HELP HERE
^nextDate
It would help to know which Smalltalk you are using.了解您使用的是哪个 Smalltalk 会有所帮助。
I will use Smalltalk/X-jv branch for the examples as it is easies for me:我将使用 Smalltalk/X-jv 分支作为示例,因为它对我来说很容易:
| lastDate nextDate |
lastDate := Date newDay: 10
month: 5
year: 2019.
nextDate := lastDate addDays: 1.
^ nextDate
To add one day you can use the #addDays:
message to your lastDate
.要添加一天,您可以使用#addDays:
消息到您的lastDate
。
Edit: due to comment编辑:由于评论
To add a year you can send message #addYears:
要添加年份,您可以发送消息#addYears:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.