简体   繁体   English

如何在每天结束时自动将值附加到数组?

[英]How do I automatically append a value to an array at the end of each day?

I am working on a calorie tracking app where the user inputs values to keep a running calorie total throughout the day. 我正在开发一个卡路里跟踪应用程序,在该应用程序中,用户输入值以保持全天运行的卡路里总量。 I would like to automatically append this daily value to an array at the end of each day so I can present running averages for the last seven days, fourteen days, and thirty days from the array data. 我想在每天结束时自动将此每日值附加到数组,以便可以显示数组数据中最近7天,14天和30天的运行平均值。

This seems like a straightforward enough issue, but I've been having trouble finding an answer or relevant example on here or googling in general. 这似乎是一个非常简单的问题,但是我一直在这里找不到答案或相关示例,或者在总体上搜寻时遇到了麻烦。 Thanks in advance for any assistance or relevant links. 在此先感谢您的协助或相关链接。

Don't append the value at the end of the day, append it the first time someone performs an action on the next day. 不要在一天结束时附加该值,而要在第二天有人第一次执行操作时附加该值。 You can use Date() to work out what day it is. 您可以使用Date()确定星期几。 If the day has changed since the last input then append the previous totals to the array. 如果自上次输入以来日期已更改,则将先前的总计添加到数组中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM