当前位置: 首页>>代码示例>>C++>>正文


C++ Date::Ceil方法代码示例

本文整理汇总了C++中Date::Ceil方法的典型用法代码示例。如果您正苦于以下问题:C++ Date::Ceil方法的具体用法?C++ Date::Ceil怎么用?C++ Date::Ceil使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Date的用法示例。


在下文中一共展示了Date::Ceil方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main (void)
{
	Date ad;
	Date bd;
	Date cd;

	printf("ad is (%s)\n", ad.GetValue()());
	printf("ad is also (%s)\n", ad.GetValue("%Y-%m-%d-%H-%M-%S")());

	bd.SetValue("07/13/2001 01:02:03.456", "%m/%d/%Y %H:%M:%S");
	printf("bd is (%s)\n", bd.GetValue()());
	printf("bd is also (%s)\n", bd.GetValue("%m/%d/%Y %H:%M:%S")());
	printf("bd is also (%s)\n", bd.GetValue("%Y%m%d%H%M%S")());
	printf("bd is also (%s)\n", bd.EDate()());
	printf("bd is also (%s)\n", bd.EDate()());
	printf("bd is also (%s)\n", bd.EDate()());
	printf("bd is also (%s)\n", bd.EDate()());

	twine tmp, tmp2;
	tmp2 = bd.EDate();
	tmp.format("Date: %s\r\n", tmp2() );
	printf("%s\n", tmp());

	printf("Before direct format\n");
	tmp.format("Date: %s\r\n", bd.GetValue("%Y%m%d%H%M%S")() );
	printf("After direct format\n");
	printf("%s", tmp() );

	printf("Before EDate format\n");
	tmp.format("Date: %s\r\n", bd.EDate()() );
	printf("After EDate format\n");
	printf("%s", tmp() );

	ad.Floor();
	bd = ad;
	bd.Ceil();

	printf("ad is (%s) bd is (%s)\n", ad.GetValue()(), bd.GetValue()());

	cd.SetValue("7/4/2001", "%m/%d/%Y");
	printf("cd is (%s)\n", cd.GetValue()());

	cd.SetValue("7/4/89", "%m/%d/%Y");
	printf("cd is (%s)\n", cd.GetValue()());

	cd.SetValue("7/4/01", "%m/%d/%Y");
	printf("cd is (%s)\n", cd.GetValue()());

	cd.SetValue("20010714080910.123", "%Y%m%d%H%M%S");
	printf("cd is (%s)\n", cd.GetValue()());

	cd.SetValue("2001/09/01 00:08:05");
	printf("Initial cd is (%s)\n", cd.GetValue()());
	cd.AddSec(-65);
	printf("cd is (%s)\n", cd.GetValue()());

	ad.SetValue("2001/08/09 12:00:00");
	bd.SetValue("2001/08/09 12:30:00");

	if(bd - ad > SLib::Interval(10, MINUTES)){
		printf("(%s) - (%s) has a difference greater than 10 minutes\n",
			bd.GetValue()(), ad.GetValue()());
	}

	if(bd - ad > SLib::Interval(20, MINUTES)){
		printf("(%s) - (%s) has a difference greater than 20 minutes\n",
			bd.GetValue()(), ad.GetValue()());
	}

	if(bd - ad > SLib::Interval(1, DAY)){
		printf("(%s) - (%s) has a difference greater than 1 day\n",
			bd.GetValue()(), ad.GetValue()());
	}

	test_conversions();

	return 0;
}
开发者ID:smc314,项目名称:SLib,代码行数:78,代码来源:test_date.cpp


注:本文中的Date::Ceil方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。