OnixS C++ FIX Engine 2.79.1.0
C:/Users/Pasha/_Dev/fixforge-cpp/fix/cppEngine/include/OnixS/FIX/Timestamp.h
00001 /*
00002 * Copyright 2005-2011 Onix Solutions Limited [OnixS]. All rights reserved. 
00003 * 
00004 * This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law 
00005 * and international copyright treaties. 
00006 * 
00007 * Access to and use of the software is governed by the terms of the applicable ONIXS Software
00008 * Services Agreement (the Agreement) and Customer end user license agreements granting 
00009 * a non-assignable, non-transferable and non-exclusive license to use the software 
00010 * for it's own data processing purposes under the terms defined in the Agreement.
00011 * 
00012 * Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part 
00013 * of this source code or associated reference material to any other location for further reproduction
00014 * or redistribution, and any amendments to this copyright notice, are expressly prohibited. 
00015 *
00016 * Any reproduction or redistribution for sale or hiring of the Software not in accordance with 
00017 * the terms of the Agreement is a violation of copyright law. 
00018 */
00019 
00020 #if !defined(__ONIXS_TIMESTAMP_H__)
00021 #define __ONIXS_TIMESTAMP_H__
00022 
00023 #include <string>
00024 
00025 #include "OnixS/FIX/ABI.h"
00026 
00027 namespace OnixS
00028 {
00029     namespace FIX
00030     {
00032         struct ONIXS_FIXENGINE_API Months
00033         {
00035             enum Enum
00036             { 
00037                 Undefined,
00038                 January,
00039                 February,
00040                 March,
00041                 April,
00042                 May,
00043                 June,
00044                 July,
00045                 August,
00046                 September,
00047                 October,
00048                 November,
00049                 December
00050             };
00051         };
00052 
00053         typedef unsigned Year;
00054         typedef Months::Enum Month;
00055         typedef unsigned Day;
00056 
00057         typedef unsigned Hour;
00058         typedef unsigned Minute;
00059         typedef unsigned Second;
00060 
00061         typedef unsigned Millisecond;
00062         typedef unsigned Microsecond;
00063         typedef unsigned Nanosecond;
00064 
00066         class ONIXS_FIXENGINE_API Timestamp
00067         {
00068         public:
00070             Timestamp();
00071 
00073             Year year() const;
00074 
00076             Month month() const;
00077 
00080             Day day() const;
00081 
00084             Hour hour() const;
00085 
00088             Minute minute() const;
00089 
00092             Second second() const;
00093 
00096             Millisecond millisecond() const;
00097 
00100             Microsecond microsecond() const;
00101 
00104             Nanosecond nanosecond() const;
00105 
00110             static Timestamp getUtc();
00111 
00116             static Timestamp getLocal();
00117 
00119             static std::string getUtcTimestampWithMilliseconds();
00120 
00122             static std::string getUtcTimestampWithNanoseconds();
00123 
00124         private:
00125             friend class TimeManager;
00126 
00127             unsigned short year_;
00128             unsigned char month_;
00129             unsigned char day_;
00130 
00131             unsigned char hour_;
00132             unsigned char minute_;
00133             unsigned char second_;
00134 
00135             unsigned int nanosecond_;
00136         };
00137 
00138         inline Year Timestamp::year() const
00139         {
00140             return year_;
00141         }
00142 
00143         inline Month Timestamp::month() const
00144         {
00145             return static_cast<Month>(month_);
00146         }
00147 
00148         inline Day Timestamp::day() const
00149         {
00150             return day_;
00151         }
00152 
00153         inline Hour Timestamp::hour() const
00154         {
00155             return hour_;
00156         }
00157 
00158         inline Minute Timestamp::minute() const
00159         {
00160             return minute_;
00161         }
00162 
00163         inline Second Timestamp::second() const
00164         {
00165             return second_;
00166         }
00167 
00168         inline Millisecond Timestamp::millisecond() const
00169         {
00170             const Nanosecond NanosecondsPerMillisecond = 1000000;
00171             return nanosecond_ / NanosecondsPerMillisecond;
00172         }
00173 
00174         inline Microsecond Timestamp::microsecond() const
00175         {
00176             const Nanosecond NanosecondsPerMicrosecond = 1000;
00177             return nanosecond_ / NanosecondsPerMicrosecond;
00178         }
00179 
00180         inline Nanosecond Timestamp::nanosecond() const
00181         {
00182             return nanosecond_;
00183         }
00184     }
00185 }
00186 
00187 #endif // __ONIXS_TIMESTAMP_H__