1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: comfunc.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
34 #include <cosv/comfunc.hxx>
35 #include <cosv/string.hxx>
37 #include <cosv/std_outp.hxx>
46 X_Default::GetInfo( ostream
& o_rOutputMedium
) const
48 o_rOutputMedium
<< "Error (general exception): ";
49 o_rOutputMedium
<< sMessage
54 count_chars(const char * str
, char c
)
57 for ( const char * pSpc
= strchr(str
, c
);
59 pSpc
= strchr(pSpc
+1, c
) )
70 str2date(const char * str
, int & out_day
, int & out_month
, int & out_year
)
78 out_day
= 10*out_day
+ *(z
++) - '0';
83 out_month
= 10*out_month
+ *(z
++) - '0';
88 out_year
= 10*out_year
+ *(z
++) - '0';
93 date2str(String
& out_Str
, int day
, int month
, int year
)
95 char buf
[11] = "00.00.0000";
96 buf
[0] = static_cast<char>(day
/10 + '0');
97 buf
[1] = static_cast<char>(day
%10 + '0');
98 buf
[3] = static_cast<char>(month
/10 + '0');
99 buf
[4] = static_cast<char>(month
%10 + '0');
103 buf
[6] = static_cast<char>(year
/10 + '0');
104 buf
[7] = static_cast<char>(year
%10 + '0');
109 buf
[6] = static_cast<char>(year
/1000 + '0');
110 buf
[7] = static_cast<char>(year
%1000/100 + '0');
111 buf
[8] = static_cast<char>(year
%100/10 + '0');
112 buf
[9] = static_cast<char>(year
%10 + '0');
118 str2time(const char * str
, int & out_hour
, int & out_min
, int & out_sec
)
120 const char * z
= str
;
126 out_hour
= 10*out_hour
+ *(z
++) - '0';
131 out_min
= 10*out_min
+ *(z
++) - '0';
136 out_sec
= 10*out_sec
+ *(z
++) - '0';
141 time2str(String
& out_Str
, int hour
, int min
, int sec
)
143 char buf
[9] = "00:00:00";
144 buf
[0] = static_cast<char>(hour
/10 + '0');
145 buf
[1] = static_cast<char>(hour
%10 + '0');
146 buf
[3] = static_cast<char>(min
/10 + '0');
147 buf
[4] = static_cast<char>(min
%10 + '0');
148 buf
[6] = static_cast<char>(sec
/10 + '0');
149 buf
[7] = static_cast<char>(sec
%10 + '0');