Aspose.Tasks for C++
WorkingTime.h
1 #pragma once
2 //-----------------------------------------------------------------------
3 // <copyright file="WorkingTime.cs" company="Aspose Pty Ltd">
4 // Copyright (c) 2002-2025 Aspose Pty Ltd. All Rights Reserved.
5 // </copyright>
6 //-----------------------------------------------------------------------
7 
8 #include <system/object.h>
9 #include <system/date_time.h>
10 #include <cstdint>
11 
12 #include "aspose.tasks.cpp/aspose_tasks_api_defs.h"
13 
14 namespace Aspose
15 {
16 namespace Tasks
17 {
18 namespace Calculations
19 {
20 class AbsWorkContourAndCalendarIterator;
21 class ActualTimephasedDataUpdater;
22 } // namespace Calculations
23 class Calendar;
24 class CalendarDatesCalculator;
25 class CalendarWorkingTimesForwardEnumerator;
26 class DatesCalculator;
27 namespace IO
28 {
29 namespace MSProject
30 {
31 class MPPTimephasedDataReader;
32 } // namespace MSProject
33 } // namespace IO
34 class TimephasedDataCalculationUtil;
35 class TimephasedDataMaker;
36 class TimeScaledExceptions;
37 namespace Util
38 {
39 class DateTimeInterval;
40 } // namespace Util
41 class WorkingTimeCollection;
42 } // namespace Tasks
43 } // namespace Aspose
44 namespace System
45 {
46 class String;
47 class TimeSpan;
48 } // namespace System
49 
50 namespace Aspose {
51 
52 namespace Tasks {
53 
54 /// <summary>
55 /// Represents a working time during a weekday.
56 /// </summary>
57 class ASPOSE_TASKS_SHARED_CLASS WorkingTime : public System::Object
58 {
59  typedef WorkingTime ThisType;
60  typedef System::Object BaseType;
61 
62  typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
63  ASPOSE_TASKS_SHARED_RTTI_INFO_DECL();
64 
65  friend class Aspose::Tasks::Calculations::AbsWorkContourAndCalendarIterator;
66  friend class Aspose::Tasks::Calculations::ActualTimephasedDataUpdater;
67  friend class Aspose::Tasks::Calendar;
68  friend class Aspose::Tasks::CalendarWorkingTimesForwardEnumerator;
69  friend class Aspose::Tasks::TimephasedDataCalculationUtil;
70  friend class Aspose::Tasks::IO::MSProject::MPPTimephasedDataReader;
71  friend class Aspose::Tasks::CalendarDatesCalculator;
72  friend class Aspose::Tasks::DatesCalculator;
73  friend class Aspose::Tasks::TimephasedDataMaker;
74  friend class Aspose::Tasks::TimeScaledExceptions;
76 
77 public:
78 
79  /// <summary>
80  /// Gets the beginning of a working time.
81  /// </summary>
82  ASPOSE_TASKS_SHARED_API System::DateTime get_From() const;
83  /// <summary>
84  /// Gets the end of a working time.
85  /// </summary>
86  ASPOSE_TASKS_SHARED_API System::DateTime get_To() const;
87 
88  /// <summary>
89  /// Initializes a new instance of the <see cref="WorkingTime"></see> class with a interval with the specified start and finish times.
90  /// </summary>
91  /// <param name="fromTime">interval start time</param>
92  /// <param name="toTime">interval end time</param>
93  ASPOSE_TASKS_SHARED_API WorkingTime(System::DateTime fromTime, System::DateTime toTime);
94  /// <summary>
95  /// Initializes a new instance of the <see cref="WorkingTime"></see> class with an interval item with the specified start and finish times.
96  /// </summary>
97  /// <param name="fromTime">Interval's start time represented by <see cref="TimeSpan"></see> struct.</param>
98  /// <param name="toTime">Interval's end time represented by <see cref="TimeSpan"></see> struct.</param>
99  /// <example>
100  /// The overload of WorkingTime ctor can be used to initialize interval's start and end using TimeSpans:
101  /// <code>
102  /// [C#]
103  /// var wt = new WorkingTime(new TimeSpan(9, 0, 0), new TimeSpan(18, 0, 0));
104  /// </code>
105  /// </example>
106  /// <exception cref="ArgumentException">When toTime less than of equal to toTime argument
107  /// or when interval between fromTime and toTime is greater than 24 hours.</exception>
108  ASPOSE_TASKS_SHARED_API WorkingTime(System::TimeSpan fromTime, System::TimeSpan toTime);
109  /// <summary>
110  /// Initializes a new instance of the <see cref="WorkingTime"></see> class with an interval item with the specified start and finish times.
111  /// </summary>
112  /// <param name="fromHours">Interval's start time represented by whole number of hours (0-24).</param>
113  /// <param name="toHours">Interval's end time represented by whole number of hours (0-24).</param>
114  /// <example>
115  /// The overload of WorkingTime ctor can be used to initialize interval's start and end using whole hours:
116  /// <code>
117  /// [C#]
118  /// var wt = new WorkingTime(9, 13);
119  /// </code>
120  /// </example>
121  /// <exception cref="ArgumentException">When toTime less than of equal to toTime argument
122  /// or when interval between fromTime and toTime is greater than 24 hours.</exception>
123  ASPOSE_TASKS_SHARED_API WorkingTime(int32_t fromHours, int32_t toHours);
124 
125  /// <summary>
126  /// Checks that the objects are equal.
127  /// </summary>
128  /// <param name="obj">Second object to compare.</param>
129  /// <returns>True if the objects are equal, false otherwise.</returns>
130  ASPOSE_TASKS_SHARED_API bool Equals(System::SharedPtr<System::Object> obj) override;
131  /// <summary>
132  /// Returns a hash code value for the instance of the <see cref="WorkingTime"></see> class.
133  /// </summary>
134  /// <returns>returns a hash code value for this object.</returns>
135  ASPOSE_TASKS_SHARED_API int32_t GetHashCode() const override;
136 
137 protected:
138 
139  ASPOSE_TASKS_SHARED_API bool get_Is24Hour();
140  ASPOSE_TASKS_SHARED_API System::TimeSpan get_Work();
141 
142  static ASPOSE_TASKS_SHARED_API System::SharedPtr<WorkingTime> CreatePrecise(System::TimeSpan from, System::TimeSpan to);
143  ASPOSE_TASKS_SHARED_API System::DateTime GetFromDate(System::DateTime date);
144  ASPOSE_TASKS_SHARED_API System::DateTime GetToDate(System::DateTime date);
145  ASPOSE_TASKS_SHARED_API System::SharedPtr<WorkingTime> GetIntersection(const System::SharedPtr<WorkingTime>& other);
146  ASPOSE_TASKS_SHARED_API System::TimeSpan GetIntersectSpan(const System::SharedPtr<WorkingTime>& other);
147  ASPOSE_TASKS_SHARED_API System::TimeSpan GetIntersectSpan(System::DateTime fromNormalized, System::DateTime toNormalized);
148  ASPOSE_TASKS_SHARED_API Util::DateTimeInterval GetInterval(System::DateTime date);
149  ASPOSE_TASKS_SHARED_API System::SharedPtr<WorkingTime> GetUnion(const System::SharedPtr<WorkingTime>& wt2);
150  ASPOSE_TASKS_SHARED_API bool Intersects(const System::SharedPtr<WorkingTime>& another);
151  ASPOSE_TASKS_SHARED_API bool Contains(System::DateTime dateTime);
152  ASPOSE_TASKS_SHARED_API bool ContainsNormalized(System::DateTime dateNormalized);
153  ASPOSE_TASKS_SHARED_API bool IsEndTime(System::DateTime dateTime);
154  #ifdef ASPOSE_GET_SHARED_MEMBERS
155  ASPOSE_TASKS_SHARED_API void GetSharedMembers(System::Object::shared_members_type& result) const override;
156  #endif
157 
158 
159 private:
160 
161  static const int64_t TicksPerMinute;
162  static const int64_t HalfTicksPerMinute;
163 
164  static System::DateTime& EndOfDay();
165 
166  System::DateTime fromTime;
167  System::DateTime toTime;
168 
169  System::String get_DebuggerDisplay();
170 
171  static System::DateTime AlignTime(System::DateTime dt);
172  void SetFromTime(System::DateTime value);
173  void SetToTime(System::DateTime value);
174 
175 };
176 
177 } // namespace Tasks
178 } // namespace Aspose
179 
180 
Definition: Asn.h:12
Represents a working time during a weekday.
Definition: WorkingTime.h:57
Represents a collection of WorkingTimeCollection objects.
Definition: WorkingTimeCollection.h:74
Represents a calendar used in a project.
Definition: Calendar.h:279
bool Contains(const System::SharedPtr< WorkingTime > &item) const override
Checks if the specified element is in the List. Performs a linear O(n) search.