time opt
发布日期:2021-06-30 22:07:54
浏览次数:3
分类:技术文章
本文共 1637 字,大约阅读时间需要 5 分钟。
用time系列函数, 取得保存当前时间.
time的F1帮助有Demo.
// MyDate.h: interface for the CMyDate class.////#if !defined(AFX_MYDATE_H__D3DBF2A4_F7DD_4B97_81B8_CFCBBAF2379F__INCLUDED_)#define AFX_MYDATE_H__D3DBF2A4_F7DD_4B97_81B8_CFCBBAF2379F__INCLUDED_#if _MSC_VER > 1000#pragma once#endif // _MSC_VER > 1000class CMyDate {public: CMyDate(int iYear, int iMonth, int iDay); virtual ~CMyDate(); void setter_date(int iYear, int iMonth, int iDay); void set_YearOffsetNow(int iYearOffsetNow); int getter_YearOffsetNow() const; ///< 得到: 离当前时间有多少年 void cpy(int iYear, int iMonth, int iDay); private: int m_iYear; int m_iMonth; int m_iDay;};#endif // !defined(AFX_MYDATE_H__D3DBF2A4_F7DD_4B97_81B8_CFCBBAF2379F__INCLUDED_)
// MyDate.cpp: implementation of the CMyDate class.////#include#include "MyDate.h"//// Construction/Destruction//CMyDate::CMyDate(int iYear, int iMonth, int iDay){ cpy(iYear, iMonth, iDay);}CMyDate::~CMyDate(){ }void CMyDate::cpy(int iYear, int iMonth, int iDay){ m_iYear = iYear; m_iMonth = iMonth; m_iDay = iDay; }void CMyDate::setter_date(int iYear, int iMonth, int iDay){ cpy(iYear, iMonth, iDay); }void CMyDate::set_YearOffsetNow(int iYearOffsetNow){ time_t tmNow; struct tm *today = NULL; // time F1 have Demo time(&tmNow); today = localtime(&tmNow); m_iYear = today->tm_year + 1900 - iYearOffsetNow; m_iMonth = today->tm_mon; m_iDay = today->tm_mday;}int CMyDate::getter_YearOffsetNow() const{ time_t tmNow; struct tm *today = NULL; time(&tmNow); today = localtime(&tmNow); return today->tm_year + 1900 - m_iYear;}
转载地址:https://lostspeed.blog.csdn.net/article/details/50323309 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
很好
[***.229.124.182]2024年04月15日 17时01分07秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
设置Golang的开发环境
2019-04-30
对HTTP/2的部分理解
2019-04-30
Golang 逃逸分析
2019-04-30
golang实现大数据量文件的排序
2019-04-30
golang中的time包
2019-04-30
golang fmt包中的占位符
2019-04-30
对Redis Cluster的理解
2019-04-30
The MASM32 SDK version 10 发布了!
2019-04-30
发布软件:TreeInfo(分层信息管理器)
2019-04-30
c++点的距离
2021-07-03
c++实现彩色炫酷(?)画面
2021-07-03
c++马拦过河卒
2021-07-03
2019NOIP D4题 加工领奖
2021-07-03
1997年世界黑客大赛获奖作品
2021-07-03
论DEV-C++怎样才能做窗口
2021-07-03
Failed to connect to github.com port 443: Operation timed out和弹出无法打开"GoogleSoftwareUpdate.bundle"
2021-07-03
2021.5.19 JS高级第二天
2021-07-03
2021.5.20 JS高级第三天
2021-07-03
2021.5.21 Jquery
2019-04-30
2021.5.25 JSON
2019-04-30