source: NonGTP/FCollada/FUtils/FUDateTime.h @ 964

Revision 964, 4.0 KB checked in by igarcia, 18 years ago (diff)
Line 
1/*
2        Copyright (C) 2006 Feeling Software Inc
3        MIT License: http://www.opensource.org/licenses/mit-license.php
4*/
5
6/**
7        @file FUDateTime.h
8        This file contains the FUDateTime class.
9*/
10
11#ifndef _FU_DATETIME_H_
12#define _FU_DATETIME_H_
13
14/**
15        A common date-time.
16        Encapsulates the OS-dependant timing functions. Use the static member function: GetNow()
17        to sample the current time. The day and month values are 1-indexed, to be user-friendly.
18
19        @ingroup FUtils
20*/
21class FCOLLADA_EXPORT FUDateTime
22{
23private:
24        // To be more friendly, 'day' and 'month' are 1-indexed
25        uint32 seconds;
26        uint32 minutes;
27        uint32 hour;
28        uint32 day;
29        uint32 month;
30        uint32 year;
31
32public:
33        /** Default constructor. The default date-time is set to 01/01/1900 at 00:00:00. */
34        FUDateTime();
35        /** Copy constructor. Creates an identical clone of the given date-time structure.
36                @param time The date-time structure to copy. */
37        FUDateTime(const FUDateTime& time);
38        /** Destructor. */
39        ~FUDateTime();
40
41        /** Retrieves the seconds component of the date-time structure.
42                @returns The seconds component. The seconds component is always in the range [0, 60[. */
43        inline uint32 GetSeconds() const { return seconds; }
44        /** Retrieves the minutes component of the date-time structure.
45                @returns The minutes component. The minutes component is always in the range [0, 60[. */
46        inline uint32 GetMinutes() const { return minutes; }
47        /** Retrieves the hour component of the date-time structure.
48                @returns The hour component. The hour component is always in the range [0, 24[. */
49        inline uint32 GetHour() const { return hour; }
50        /** Retrieves the day component of the date-time structure.
51                @returns The day component. The day component is 1-indexed and has an upper range
52                        that depends on the month component. The valid range for the day component is [1, 31].*/
53        inline uint32 GetDay() const { return day; }
54        /** Retrieves the month component of the date-time structure.
55                @returns The month component. The month component is 1-indexed and is always in the range [1, 12].*/
56        inline uint32 GetMonth() const { return month; }
57        /** Retrieves the year component of the date-time structure.
58                @returns The year component. The year component represents the full year value,
59                        where a value of 2000 is returned for the year 2000.*/
60        inline uint32 GetYear() const { return year; }
61
62        /** Sets the seconds component of the date-time structure.
63                @param _seconds The new seconds value. No verification is made
64                        to verify that the new value is within the valid range. */
65        inline void SetSeconds(uint32 _seconds) { seconds = _seconds; }
66        /** Sets the minutes component of the date-time structure.
67                @param _minutes The new seconds value. No verification is made
68                        to verify that the new value is within the valid range. */
69        inline void SetMinutes(uint32 _minutes) { minutes = _minutes; }
70        /** Sets the hour component of the date-time structure.
71                @param _hour The new seconds value. No verification is made
72                        to verify that the new value is within the valid range. */
73        inline void SetHour(uint32 _hour) { hour = _hour; }
74        /** Sets the day component of the date-time structure.
75                @param _day The new seconds value. No verification is made
76                        to verify that the new value is within the valid range. */
77        inline void SetDay(uint32 _day) { day = _day; }
78        /** Sets the month component of the date-time structure.
79                @param _month The new seconds value. No verification is made
80                        to verify that the new value is within the valid range. */
81        inline void SetMonth(uint32 _month) { month = _month; }
82        /** Sets the year component of the date-time structure.
83                @param _year The new seconds value. No verification is made
84                        to verify that the new value is within the valid range. */
85        inline void SetYear(uint32 _year) { year = _year; }
86
87        /** Creates a date-time structure to represent the current time.
88                Encapsulates the OS-dependant time() function.
89                @return The current date-time. */
90        static FUDateTime GetNow();
91};
92
93#endif // _FU_DATETIME_H_
Note: See TracBrowser for help on using the repository browser.