Example #1
0
//============================================================================
//		NDate::GetDayOfYear : Get the day of the year.
//----------------------------------------------------------------------------
NIndex NDate::GetDayOfYear(const NString &timeZone) const
{   NGregorianDate		yearStart;
    NTime				theDelta;
    NIndex				theIndex;



    // Get the day
    yearStart = GetYearStart(timeZone);
    theDelta  = *this - NDate(yearStart);
    theIndex  = ((NIndex) floor(theDelta / kNTimeDay)) + 1;

    return(theIndex);
}
Example #2
0
//============================================================================
//		NDate::GetWeekOfYear : Get the week of the year.
//----------------------------------------------------------------------------
NIndex NDate::GetWeekOfYear(const NString &timeZone) const
{   NGregorianDate		yearStart, theDate;
    NTime				theDelta;
    NIndex				theIndex;



    // Get the week
    //
    // The first week contains the 4th of January.
    theDate = GetDate(timeZone);

    if (theDate.month == 1 && theDate.day <= 4)
        theIndex = 1;
    else
    {
        yearStart = GetYearStart(timeZone, 4);
        theDelta  = *this - NDate(yearStart);
        theIndex  = ((NIndex) floor(theDelta / kNTimeWeek)) + 1;
    }

    return(theIndex);
}
Example #3
0
static const NString kKeyNumber										= "Test Number";
static const NString kKeyData										= "Test Data";
static const NString kKeyDate										= "Test Date";
static const NString kKeyColor										= "Test Color";


// Values
static const NString kValueString1									= "First String";
static const NString kValueString2									= "Second String";
static const bool    kValueBoolean1									= true;
static const bool    kValueBoolean2									= false;
static const SInt64  kValueNumber1									= -2342;
static const Float64 kValueNumber2									= kNPi;
static const UInt8   kValueData1[]									= { 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A };
static const UInt8   kValueData2[]									= { 0x3C, 0xE7, 0xC7, 0x32, 0xE3, 0xD8, 0x52 };
static const NDate   kValueDate1									= NDate(-886538221);
static const NDate   kValueDate2									= NDate( 268617632);
static const NColor  kValueColor1									= NColor(1.0f, 0.8f, 0.4f, 0.2f);
static const NColor  kValueColor2									= NColor(0.1f, 0.2f, 0.3f, 0.4f);


// Property lists
static const NString kPropertyListXML								=	"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
																		"<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n"
																		"<plist version=\"1.0\">\n"
																		"<dict>\n"
																		"	<key>Test Array</key>\n"
																		"	<array>\n"
																		"		<string>First String</string>\n"
																		"		<true/>\n"
																		"		<integer>-2342</integer>\n"
Example #4
0




//============================================================================
//		Test case
//----------------------------------------------------------------------------
TEST_NDATE("Conversion")
{	NGregorianDate		gregDate;



	// Perform the test
	gregDate = theDate.GetDate(kNTimeZoneUTC);
	REQUIRE(NDate(gregDate) == NDate(kTestDate1));

	gregDate = theDate.GetDate(kNTimeZonePDT);
	REQUIRE(NDate(gregDate) == NDate(kTestDate2));

	gregDate = theDate.GetDate(kNTimeZoneCEST);
	REQUIRE(NDate(gregDate) == NDate(kTestDate3));
}





//============================================================================
//		Test case
//----------------------------------------------------------------------------