定义一个时间类,能根据系统当前时间计算年龄.类中包含年月日.
来源:学生作业帮助网 编辑:作业帮 时间:2024/06/23 12:34:46
![定义一个时间类,能根据系统当前时间计算年龄.类中包含年月日.](/uploads/image/z/14861996-44-6.jpg?t=%E5%AE%9A%E4%B9%89%E4%B8%80%E4%B8%AA%E6%97%B6%E9%97%B4%E7%B1%BB%2C%E8%83%BD%E6%A0%B9%E6%8D%AE%E7%B3%BB%E7%BB%9F%E5%BD%93%E5%89%8D%E6%97%B6%E9%97%B4%E8%AE%A1%E7%AE%97%E5%B9%B4%E9%BE%84.%E7%B1%BB%E4%B8%AD%E5%8C%85%E5%90%AB%E5%B9%B4%E6%9C%88%E6%97%A5.)
定义一个时间类,能根据系统当前时间计算年龄.类中包含年月日.
定义一个时间类,能根据系统当前时间计算年龄.类中包含年月日.
定义一个时间类,能根据系统当前时间计算年龄.类中包含年月日.
#ifndef _DATE_TIME_H
#define _DTTE_TIME_H
#include
int get_year(){
\x09time_t t;
\x09struct tm *l;\x09
\x09t = time(&t);
\x09l = localtime(&t);\x09
return (l->tm_year + 1900);}
int get_month(){
\x09time_t t;
\x09struct tm *l;\x09
\x09t = time(&t);
\x09l = localtime(&t);
return (l->tm_mon+1);}
int get_day(){
\x09time_t t;
\x09struct tm *l;\x09
\x09t = time(&t);
\x09l = localtime(&t);
return (l->tm_mday);}
int get_hour(){
\x09time_t t;
\x09struct tm *l;\x09
\x09t = time(&t);
\x09l = localtime(&t);
return (l->tm_hour);}
int get_minuts(){
\x09time_t t;
\x09struct tm *l;\x09
\x09t = time(&t);
\x09l = localtime(&t);
return (l->tm_min);}
int get_seconds(){
\x09time_t t;
\x09struct tm *l;\x09
\x09t = time(&t);
\x09l = localtime(&t);
return (l->tm_sec);}
int get_week(){
\x09time_t t;
\x09struct tm *l;\x09
\x09t = time(&t);
\x09l = localtime(&t);
return (l->tm_wday);}
#endif