Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Main
Synchronet
Commits
60fb2d09
Commit
60fb2d09
authored
19 years ago
by
rswindell
Browse files
Options
Downloads
Patches
Plain Diff
Created xpTimeZone_t typedef.
Re-introduced xpTimeZone_t to isoDate/Time_t conversion functions.
parent
884da07b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/xpdev/datewrap.c
+22
-2
22 additions, 2 deletions
src/xpdev/datewrap.c
src/xpdev/datewrap.h
+28
-20
28 additions, 20 deletions
src/xpdev/datewrap.h
with
50 additions
and
22 deletions
src/xpdev/datewrap.c
+
22
−
2
View file @
60fb2d09
...
...
@@ -56,7 +56,7 @@ time_t sane_mktime(struct tm* tm)
xpDateTime_t
xpDateTime_create
(
unsigned
year
,
unsigned
month
,
unsigned
day
,
unsigned
hour
,
unsigned
minute
,
float
second
,
in
t
zone
)
,
xpTimeZone_
t
zone
)
{
xpDateTime_t
xpDateTime
;
...
...
@@ -136,6 +136,26 @@ xpDateTime_t time_to_xpDateTime(time_t time)
/* Decimal-coded ISO-8601 date/time functions */
/**********************************************/
isoDate_t
xpDateTime_to_isoDateTime
(
xpDateTime_t
xpDateTime
,
isoTime_t
*
isoTime
)
{
if
(
isoTime
!=
NULL
)
*
isoTime
=
0
;
if
(
xpDateTime
.
date
.
year
==
0
)
return
(
0
);
if
(
isoTime
!=
NULL
)
*
isoTime
=
isoTime_create
(
xpDateTime
.
time
.
hour
,
xpDateTime
.
time
.
minute
,
xpDateTime
.
time
.
second
);
return
isoDate_create
(
xpDateTime
.
date
.
year
,
xpDateTime
.
date
.
month
,
xpDateTime
.
date
.
day
);
}
xpDateTime_t
isoDateTime_to_xpDateTime
(
isoDate_t
date
,
isoTime_t
time
)
{
return
xpDateTime_create
(
isoDate_year
(
date
),
isoDate_month
(
date
),
isoDate_day
(
date
)
,
isoTime_hour
(
time
),
isoTime_minute
(
time
),(
float
)
isoTime_second
(
time
),
LOCAL_UTC_DIFF
);
}
isoDate_t
time_to_isoDateTime
(
time_t
time
,
isoTime_t
*
isoTime
)
{
struct
tm
tm
;
...
...
@@ -185,7 +205,7 @@ time_t isoDateTime_to_time(isoDate_t date, isoTime_t time)
return
sane_mktime
(
&
tm
);
}
BOOL
isoTimeZone_parse
(
const
char
*
str
,
in
t
*
zone
)
BOOL
isoTimeZone_parse
(
const
char
*
str
,
xpTimeZone_
t
*
zone
)
{
unsigned
hour
=
0
,
minute
=
0
;
...
...
This diff is collapsed.
Click to expand it.
src/xpdev/datewrap.h
+
28
−
20
View file @
60fb2d09
...
...
@@ -62,15 +62,17 @@ typedef struct {
float
second
;
/* supports fractional seconds */
}
xpTime_t
;
typedef
int
xpTimeZone_t
;
typedef
struct
{
xpDate_t
date
;
xpTime_t
time
;
int
zone
;
/* minutes +/- UTC */
xpDate_t
date
;
xpTime_t
time
;
xpTimeZone_t
zone
;
/* minutes +/- UTC */
}
xpDateTime_t
;
xpDateTime_t
xpDateTime_create
(
unsigned
year
,
unsigned
month
,
unsigned
day
,
unsigned
hour
,
unsigned
minute
,
float
second
,
int
z
one
);
,
xpTimeZ
one
_t
);
xpDateTime_t
xpDateTime_now
(
void
);
time_t
xpDateTime_to_time
(
xpDateTime_t
);
xpDateTime_t
time_to_xpDateTime
(
time_t
);
...
...
@@ -82,31 +84,37 @@ xpDateTime_t time_to_xpDateTime(time_t);
typedef
ulong
isoDate_t
;
/* CCYYMMDD (decimal) */
typedef
uint
isoTime_t
;
/* HHMMSS (decimal) */
#define isoDate_create(year,mon,day) (((year)*10000)+((mon)*100)+(day))
#define isoTime_create(hour,min,sec) (((hour)*10000)+((min)*100)+(sec))
#define isoDate_year(date) ((date)/10000)
#define isoDate_month(date) (((date)/100)%100)
#define isoDate_day(date) ((date)%100)
#define isoTime_hour(time) ((time)/10000)
#define isoTime_minute(time) (((time)/100)%100)
#define isoTime_second(time) ((time)%100)
#define isoDate_create(year,mon,day) (((year)*10000)+((mon)*100)+(day))
#define isoTime_create(hour,min,sec) (((hour)*10000)+((min)*100)+((unsigned)sec))
#define isoDate_year(date) ((date)/10000)
#define isoDate_month(date) (((date)/100)%100)
#define isoDate_day(date) ((date)%100)
#define isoTime_hour(time) ((time)/10000)
#define isoTime_minute(time) (((time)/100)%100)
#define isoTime_second(time) ((time)%100)
BOOL
isoTimeZone_parse
(
const
char
*
str
,
xpTimeZone_t
*
);
xpDateTime_t
isoDateTime_parse
(
const
char
*
str
);
/**********************************************/
/* Conversion between time_t and isoDate/Time */
/**********************************************/
isoTime_t
time_to_isoTime
(
time_t
);
isoDate_t
time_to_isoDateTime
(
time_t
,
isoTime_t
*
);
time_t
isoDateTime_to_time
(
isoDate_t
date
,
isoTime_t
time
);
BOOL
isoTimeZone_parse
(
const
char
*
str
,
int
*
zone
);
xpDateTime_t
isoDateTime_parse
(
const
char
*
str
);
time_t
isoDateTime_to_time
(
isoDate_t
,
isoTime_t
);
#define time_to_isoDate(t) time_to_isoDateTime(t,NULL)
/***************************************************/
/* Conversion between xpDate/Time and isoDate/Time */
/***************************************************/
#define xpDate_to_isoDate(date) isoDate_create((date).year,(date).month,(date).day)
#define xpTime_to_isoTime(time) isoTime_create((time).hour,(time).minute,(unsigned)((time).second))
#define xpDate_to_isoDate(date) isoDate_create((date).year,(date).month,(date).day)
#define xpTime_to_isoTime(time) isoTime_create((time).hour,(time).minute,(unsigned)((time).second))
xpDateTime_t
isoDateTime_to_xpDateTime
(
isoDate_t
,
isoTime_t
);
isoDate_t
xpDateTime_to_isoDateTime
(
xpDateTime_t
,
isoTime_t
*
);
/***********************************/
/* Borland DOS date/time functions */
...
...
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