Time_T舍入到几分钟
time_t rounded to minutes
我正在使用处理时间_t的API。现在,我也有一个API的结果,该结果也可以在time_t中检索数据,但是问题是第一个只需要日期,小时和分钟,但是我检索到的数据包括秒,我如何从数据>
m_chart.period = PERIOD_M1;
m_chart.start = m_trades[x].open_time;
m_chart.end = m_trades[x].close_time;
m_chart.mode = CHART_RANGE_IN;
candles = m_manager->ChartRequest(&m_chart, &stamp, &chart_total);
其中m_trades [x] .open_time是我检索到秒的数据,而m_chart.start是仅需要日期,小时和分钟的过滤器数据。
我希望您能帮助我解决这个问题。
谢谢。
time_t
在几秒钟内,因此,如果您只包含一个圆形分钟,则必须减去剩余的秒数:
t -= (t % 60) // minutes_only_sec = total_seconds - seconds_reminder_seconds
例如
time_t secs = 2 * 60 + 14; // 2:14
time_t min_only = (secs - secs % 60);
std::cout << "seconds:" << secs << " / " << min_only << std::endl;
std::cout << "minutes: " << secs / 60 << ":" << (secs % 60)
<< " / " << min_only / 60 << ":" << (min_only % 60) << std::endl;
具有以下输出:
秒:134/120
分钟2:14/2:0
,如果您想围绕它进行测试:
if (secs % 60)
{
min_only += 60;
}
我建议使用std::chrono::duration
。它更长了:
time_t min_only = std::chrono::seconds(
std::chrono::duration_cast<std::chrono::minutes>(std::chrono::seconds(secs))
).count();
相关文章:
- Boost::posix_time::ptime舍入到给定的分钟数
- 填孔方法需要20分钟以上
- 每秒清除一次终端,但留下几分钟
- WinAPI BitBlt冻结几分钟
- 高频插入 PostgreSQL,插入的数据要到几分钟后才能选择?
- fopen 几分钟后无法打开文件
- 如何杀死等待超过一分钟或 2 分钟的线程C++
- Time_T舍入到几分钟
- 将几秒钟转换为几天,小时,分钟,秒格式(C )
- 将几秒钟转换为小时数分钟的公式是什么?
- 从STD :: String Boost C 获取小时和几分钟
- 将年龄在几年,小时,几分钟和秒的时间内转换
- 动态分配的工作线程在几分钟后泄漏,尽管它不应该
- 将文件数据延迟几分钟
- 在终止/非活动会话上执行简单查询需要几分钟时间
- 为什么Windows服务控制管理器需要几分钟来处理请求
- SQL server timestamp_t的Boost ptime关闭了几分钟.我做错了什么?
- SDL_Surface在游戏运行几分钟后消失
- c++程序需要几分钟来解析大文件,而python只需要几秒钟
- 方法在c++中每隔几分钟调用一个函数