Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
0b396ef1
Commit
0b396ef1
authored
Dec 14, 2011
by
Hugo Beauzée-Luyssen
Committed by
Jean-Baptiste Kempf
Dec 30, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
strings: Adding an helper to convert iso8601 durations
Signed-off-by:
Jean-Baptiste Kempf
<
jb@videolan.org
>
parent
fb10d756
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
62 additions
and
0 deletions
+62
-0
include/vlc_strings.h
include/vlc_strings.h
+2
-0
src/libvlccore.sym
src/libvlccore.sym
+1
-0
src/text/strings.c
src/text/strings.c
+59
-0
No files found.
include/vlc_strings.h
View file @
0b396ef1
...
@@ -53,6 +53,8 @@ VLC_API char * str_format( vlc_object_t *, const char * );
...
@@ -53,6 +53,8 @@ VLC_API char * str_format( vlc_object_t *, const char * );
VLC_API
void
filename_sanitize
(
char
*
);
VLC_API
void
filename_sanitize
(
char
*
);
VLC_API
void
path_sanitize
(
char
*
);
VLC_API
void
path_sanitize
(
char
*
);
VLC_API
time_t
str_duration
(
const
char
*
);
/**
/**
* @}
* @}
*/
*/
...
...
src/libvlccore.sym
View file @
0b396ef1
...
@@ -419,6 +419,7 @@ stream_vaControl
...
@@ -419,6 +419,7 @@ stream_vaControl
str_format
str_format
str_format_meta
str_format_meta
str_format_time
str_format_time
str_duration
subpicture_Delete
subpicture_Delete
subpicture_New
subpicture_New
subpicture_NewFromPicture
subpicture_NewFromPicture
...
...
src/text/strings.c
View file @
0b396ef1
...
@@ -1275,3 +1275,62 @@ out:
...
@@ -1275,3 +1275,62 @@ out:
free
(
path
);
free
(
path
);
return
ret
;
/* unknown scheme */
return
ret
;
/* unknown scheme */
}
}
/*
Decodes a duration as defined by ISO 8601
http://en.wikipedia.org/wiki/ISO_8601#Durations
@param str A null-terminated string to convert
@return: The duration in seconds. -1 if an error occured.
Exemple input string: "PT0H9M56.46S"
*/
time_t
str_duration
(
const
char
*
psz_duration
)
{
bool
timeDesignatorReached
=
false
;
time_t
res
=
0
;
char
*
end_ptr
;
if
(
psz_duration
==
NULL
)
return
-
1
;
if
(
(
*
(
psz_duration
++
)
)
!=
'P'
)
return
-
1
;
do
{
double
number
=
strtod
(
psz_duration
,
&
end_ptr
);
double
mul
=
0
;
if
(
psz_duration
!=
end_ptr
)
psz_duration
=
end_ptr
;
switch
(
*
psz_duration
)
{
case
'M'
:
{
//M can mean month or minutes, if the 'T' flag has been reached.
//We don't handle months though.
if
(
timeDesignatorReached
==
true
)
mul
=
60
.
0
;
break
;
}
case
'Y'
:
case
'W'
:
break
;
//Don't handle this duration.
case
'D'
:
mul
=
86400
.
0
;
break
;
case
'T'
:
timeDesignatorReached
=
true
;
break
;
case
'H'
:
mul
=
3600
.
0
;
break
;
case
'S'
:
mul
=
1
.
0
;
break
;
default:
break
;
}
res
+=
(
time_t
)(
mul
*
number
);
if
(
*
psz_duration
)
psz_duration
++
;
}
while
(
*
psz_duration
);
return
res
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment