<commit_before>/*
 * Copyright(c) Sophist Solutions, Inc. 1990-2011.  All rights reserved
 */
#ifndef	_Stroika_Foundation_Time_Duration_h_
#define	_Stroika_Foundation_Time_Duration_h_	1

#include	"../StroikaPreComp.h"

#include	<climits>
#include	<string>

#if		qPlatform_Windows
	#include	<Windows.h>
#endif

#include	"../Configuration/Common.h"
#include	"../Execution/StringException.h"



/*
 * TODO:
 *
 *		o	Do better job rounding. Right now we round (?)properly for seconds, but nothing else.
 *
 *		o	Add support for long double (and perhaps others?). And consider using long double for InternalNumericFormatType_;
 *
 *		o	Consider adding 'precision' property to PrettyPrintInfo. Think about precision support/design of
 *			boost (maybe use  bignum or rational?). Probably no - but document clearly why or why not.
 *
 */


namespace	Stroika {
	namespace	Foundation {
		namespace	Time {


			/*
			 * (basic) support for ISO 8601 Durations
			 *		http://en.wikipedia.org/wiki/ISO_8601#Durations
			 *
			 *	Note: according to glibc docs - year is always 365 days, month always 30 days, etc, as far as these duration objects
			 *	go - at least for conversion to/from time_t. Seek a better reference for this claim!
			 *
			 * Note also - there are two iso 8601 duration formats - one date like (YYYY-MM....) and this one P...T...3S).
			 * As far as I know - XML always uses the later. For now - this implementation only supports the later.
			 *
			 *		See also: http://bugzilla/show_bug.cgi?id=468
			 */
			class	Duration {
				public:
					// Throws (FormatException) if bad format
					Duration ();
					explicit Duration (const wstring& durationStr);
					explicit Duration (int32_t duration);
					explicit Duration (int64_t duration);
					explicit Duration (double duration);

				public:
					nonvirtual	void	clear ();
					nonvirtual	bool	empty () const;<commit_msg>Date/Time comments<commit_after>/*
 * Copyright(c) Sophist Solutions, Inc. 1990-2011.  All rights reserved
 */
#ifndef	_Stroika_Foundation_Time_Duration_h_
#define	_Stroika_Foundation_Time_Duration_h_	1

#include	"../StroikaPreComp.h"

#include	<climits>
#include	<string>

#if		qPlatform_Windows
	#include	<Windows.h>
#endif

#include	"../Configuration/Common.h"
#include	"../Execution/StringException.h"



/*
 * TODO:
 *
 *		o	Do better job rounding. Right now we round (?)properly for seconds, but nothing else.
 *
 *		o	Add support for long double (and perhaps others?). And consider using long double for InternalNumericFormatType_;
 *
 *		o	Consider adding 'precision' property to PrettyPrintInfo. Think about precision support/design of
 *			boost (maybe use  bignum or rational?). Probably no - but document clearly why or why not.
 *
 *		o	Add PRECISION support to PrettyPrintInfo argument to PrettyPrint () function.
 *			o	Number of seconds. Anything less than that number is truncated.
 *			o	So .001 precision means show 3.44444 as 3.444 and 60 means show 67 seconds as one minute
 *			o	Maybe add option so can show > or < as in < one minute or > one minute for being passed sentainl values?
 *
 *
 */


namespace	Stroika {
	namespace	Foundation {
		namespace	Time {


			/*
			 * (basic) support for ISO 8601 Durations
			 *		http://en.wikipedia.org/wiki/ISO_8601#Durations
			 *
			 *	Note: according to glibc docs - year is always 365 days, month always 30 days, etc, as far as these duration objects
			 *	go - at least for conversion to/from time_t. Seek a better reference for this claim!
			 *
			 * Note also - there are two iso 8601 duration formats - one date like (YYYY-MM....) and this one P...T...3S).
			 * As far as I know - XML always uses the later. For now - this implementation only supports the later.
			 *
			 *		See also: http://bugzilla/show_bug.cgi?id=468
			 *
			 *	This class is roughly equivilent to the .Net Timespan class, and also might be called "time period".
			 *
			 *	Note that a Duration maybe negative.
			 *
			 *	It is best to logically think of Duration as a number of seconds (at least lossly)  since for comparisons 
			 *	thats how things are normalized. #days etc are dumbed down to number of seconds for comparison sakes.
			 */
			class	Duration {
				public:
					// Throws (FormatException) if bad format
					Duration ();
					explicit Duration (const wstring& durationStr);
					explicit Duration (int32_t duration);
					explicit Duration (int64_t duration);
					explicit Duration (double duration);

				public:
					nonvirtual	void	clear ();
					nonvirtual	bool	empty () const;
{'fraction_non_alphanumeric': 0.08772316508706193, 'fraction_numerical': 0.01873484681507604, 'mean_word_length': 3.15948670944088, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '408989', 'n_tokens_mistral': 1618, 'n_tokens_neox': 1331, 'n_words': 534}