# ecdate **Repository Path**: DrDaemon_admin/ecdate ## Basic Information - **Project Name**: ecdate - **Description**: C++封装的日期类,简单易用,包括 Duration:时间段、Date:日期类 、Time时间类。 支持 时间/日期 加/减/比较,时间戳/字符串 相互转换。 - **Primary Language**: C++ - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 25 - **Created**: 2022-07-15 - **Last Updated**: 2023-04-21 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # overview a c++ date class the namespace is ec ``` using namespace ec; ``` include three class - Duration: a period of time - Date: convenient for date of operation - Time: the precise time # detail Please directly add the source code to your project The source code in the "src" directory. example: --- ``` #include #include "date.h" int main(int argc, char *argv[]) { // The current time ec::Time now; // 10 hours ec::Duration d(10, ec::Duration::Hour); // After 10 hours now += d; // output like 2016-01-01 12:00:00 std::cout << now.toString() << std::endl; return 0; } ``` ## Duration ``` // 10 days ec::Duration d0(10, ec::Duration::Day); // 240 hours ec::Duration d1 = d0.down(); // 864000 seconds int64 seconds = d0.valueAs(ec::Duration::Second); ``` ## Date ``` // 2016-01-01 00:00:00 ec::Date d0(2016, 1, 1, 0, 0, 0); // 2016-01-02 00:00:00 d0.add(ec::Duration(1, ec::Duration::Day); // 2015-01-02 00:00:00 d0.setYear(2015); ``` ## Time ``` // The current time ec::Time t0; // 2016-01-01 00:00:00 ec::Time t1(ec::Date(2016, 1, 1)); // seconds int64 seconds = t1.diff(t0, ec::Duration::Second); ``` # 中文简介 这是C++简单对时间操作的封装,命名空间为ec 包含三个类: Duration: 时间段 Date: 日期类 Time: 时间类 由于代码比较简单,没有提供编辑成链接库的makefile,请直接将源代码(src目录 )加入你的工程。