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