Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
E
ECSS Services
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AcubeSat-OBC
ECSS Services
Commits
9082107a
Commit
9082107a
authored
6 years ago
by
Theodoros Katzalis
Browse files
Options
Downloads
Patches
Plain Diff
Added two functions that perform date comparison
parent
f75f5bd6
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.idea/codeStyles/Project.xml
+0
-19
0 additions, 19 deletions
.idea/codeStyles/Project.xml
inc/Helpers/TimeHelper.hpp
+23
-0
23 additions, 0 deletions
inc/Helpers/TimeHelper.hpp
src/Helpers/TimeHelper.cpp
+95
-3
95 additions, 3 deletions
src/Helpers/TimeHelper.cpp
with
118 additions
and
22 deletions
.idea/codeStyles/Project.xml
+
0
−
19
View file @
9082107a
...
...
@@ -3,25 +3,6 @@
<option
name=
"RIGHT_MARGIN"
value=
"100"
/>
<option
name=
"WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN"
value=
"true"
/>
<Objective-C-extensions>
<file>
<option
name=
"com.jetbrains.cidr.lang.util.OCDeclarationKind"
value=
"Import"
/>
<option
name=
"com.jetbrains.cidr.lang.util.OCDeclarationKind"
value=
"Macro"
/>
<option
name=
"com.jetbrains.cidr.lang.util.OCDeclarationKind"
value=
"Typedef"
/>
<option
name=
"com.jetbrains.cidr.lang.util.OCDeclarationKind"
value=
"Enum"
/>
<option
name=
"com.jetbrains.cidr.lang.util.OCDeclarationKind"
value=
"Constant"
/>
<option
name=
"com.jetbrains.cidr.lang.util.OCDeclarationKind"
value=
"Global"
/>
<option
name=
"com.jetbrains.cidr.lang.util.OCDeclarationKind"
value=
"Struct"
/>
<option
name=
"com.jetbrains.cidr.lang.util.OCDeclarationKind"
value=
"FunctionPredecl"
/>
<option
name=
"com.jetbrains.cidr.lang.util.OCDeclarationKind"
value=
"Function"
/>
</file>
<class>
<option
name=
"com.jetbrains.cidr.lang.util.OCDeclarationKind"
value=
"Property"
/>
<option
name=
"com.jetbrains.cidr.lang.util.OCDeclarationKind"
value=
"Synthesize"
/>
<option
name=
"com.jetbrains.cidr.lang.util.OCDeclarationKind"
value=
"InitMethod"
/>
<option
name=
"com.jetbrains.cidr.lang.util.OCDeclarationKind"
value=
"StaticMethod"
/>
<option
name=
"com.jetbrains.cidr.lang.util.OCDeclarationKind"
value=
"InstanceMethod"
/>
<option
name=
"com.jetbrains.cidr.lang.util.OCDeclarationKind"
value=
"DeallocMethod"
/>
</class>
<extensions>
<pair
source=
"cpp"
header=
"hpp"
fileNamingConvention=
"PASCAL_CASE"
/>
<pair
source=
"c"
header=
"h"
fileNamingConvention=
"NONE"
/>
...
...
This diff is collapsed.
Click to expand it.
inc/Helpers/TimeHelper.hpp
+
23
−
0
View file @
9082107a
...
...
@@ -82,6 +82,29 @@ public:
TimeHelper
()
=
default
;
/**
* @param Now the date provided from the Real Time Clock(UTC format)
* @param Date the date that will be compared with the \p Now
* @param equalCondition if it is true, then this function returns true when the dates
* are equal. If the \p equalCondition is false, then this function returns false when
* the dates are equal
* @return true if \p Now is greater than \p DateExamined. The equality depends on the \p
* equalCondition
*/
bool
IsAfter
(
struct
TimeAndDate
&
Now
,
struct
TimeAndDate
&
Date
,
bool
equalCondition
);
/**
* @param Now the date provided from the Real Time Clock(UTC format)
* @param Date the date that will be compared with the \p Now
* @param equalCondition if it is true, then this function returns true when the dates
* are equal. If the \p equalCondition is false, then this function returns false when
* the dates are equal.
* @return true if \p Now is smaller than \p DateExamined. The equality depends on the \p
* equalCondition
*/
bool
IsBefore
(
struct
TimeAndDate
&
Now
,
struct
TimeAndDate
&
Date
,
bool
equalCondition
);
/**
* Generate the CDS time format(3.3 in CCSDS 301.0-B-4 standard).
*
...
...
This diff is collapsed.
Click to expand it.
src/Helpers/TimeHelper.cpp
+
95
−
3
View file @
9082107a
...
...
@@ -61,16 +61,16 @@ struct TimeAndDate TimeHelper::utcTime(uint32_t seconds) {
}
// calculate days
TimeInfo
.
day
=
seconds
/
SecondsPerDay
;
TimeInfo
.
day
=
seconds
/
SecondsPerDay
;
seconds
-=
TimeInfo
.
day
*
SecondsPerDay
;
TimeInfo
.
day
++
;
// add 1 day because we start count from 1 January(and not 0 January!)
// calculate hours
TimeInfo
.
hour
=
seconds
/
SecondsPerHour
;
TimeInfo
.
hour
=
seconds
/
SecondsPerHour
;
seconds
-=
TimeInfo
.
hour
*
SecondsPerHour
;
// calculate minutes
TimeInfo
.
minute
=
seconds
/
SecondsPerMinute
;
TimeInfo
.
minute
=
seconds
/
SecondsPerMinute
;
seconds
-=
TimeInfo
.
minute
*
SecondsPerMinute
;
// calculate seconds
...
...
@@ -79,6 +79,98 @@ struct TimeAndDate TimeHelper::utcTime(uint32_t seconds) {
return
TimeInfo
;
}
bool
TimeHelper
::
IsAfter
(
struct
TimeAndDate
&
Now
,
struct
TimeAndDate
&
Date
,
bool
equalCondition
)
{
// compare years
if
(
Now
.
year
>
Date
.
year
)
{
return
true
;
}
else
if
(
Now
.
year
<
Date
.
year
)
{
return
false
;
}
// compare months
if
(
Now
.
month
>
Date
.
month
)
{
return
true
;
}
else
if
(
Now
.
month
<
Date
.
month
)
{
return
false
;
}
// compare days
if
(
Now
.
day
>
Date
.
day
)
{
return
true
;
}
else
if
(
Now
.
day
<
Date
.
day
)
{
return
false
;
}
// compare hours
if
(
Now
.
hour
>
Date
.
hour
)
{
return
true
;
}
else
if
(
Now
.
hour
<
Date
.
hour
)
{
return
false
;
}
// compare minutes
if
(
Now
.
minute
>
Date
.
minute
)
{
return
true
;
}
else
if
(
Now
.
minute
<
Date
.
minute
)
{
return
false
;
}
// compare seconds
if
(
Now
.
second
>
Date
.
second
)
{
return
true
;
}
else
if
(
Now
.
second
<
Date
.
second
)
{
return
false
;
}
else
if
(
Now
.
second
==
Date
.
second
)
return
equalCondition
;
}
bool
TimeHelper
::
IsBefore
(
struct
TimeAndDate
&
Now
,
struct
TimeAndDate
&
Date
,
bool
equalCondition
)
{
// compare years
if
(
Now
.
year
<
Date
.
year
)
{
return
true
;
}
else
if
(
Now
.
year
>
Date
.
year
)
{
return
false
;
}
// compare months
if
(
Now
.
month
<
Date
.
month
)
{
return
true
;
}
else
if
(
Now
.
month
>
Date
.
month
)
{
return
false
;
}
// compare days
if
(
Now
.
day
<
Date
.
day
)
{
return
true
;
}
else
if
(
Now
.
day
>
Date
.
day
)
{
return
false
;
}
// compare hours
if
(
Now
.
hour
<
Date
.
hour
)
{
return
true
;
}
else
if
(
Now
.
hour
>
Date
.
hour
)
{
return
false
;
}
// compare minutes
if
(
Now
.
minute
<
Date
.
minute
)
{
return
true
;
}
else
if
(
Now
.
minute
>
Date
.
minute
)
{
return
false
;
}
// compare seconds
if
(
Now
.
second
<
Date
.
second
)
{
return
true
;
}
else
if
(
Now
.
second
>
Date
.
second
)
{
return
false
;
}
else
if
(
Now
.
second
==
Date
.
second
)
return
equalCondition
;
}
uint64_t
TimeHelper
::
generateCDStimeFormat
(
struct
TimeAndDate
&
TimeInfo
)
{
/**
* Define the T-field. The total number of octets for the implementation of T-field is 6(2 for
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment