1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
31 #include <cosv/comfunc.hxx>
32 #include <cosv/string.hxx>
34 #include <cosv/std_outp.hxx>
43 X_Default::GetInfo( ostream
& o_rOutputMedium
) const
45 o_rOutputMedium
<< "Error (general exception): ";
46 o_rOutputMedium
<< sMessage
51 count_chars(const char * str
, char c
)
54 for ( const char * pSpc
= strchr(str
, c
);
56 pSpc
= strchr(pSpc
+1, c
) )
67 str2date(const char * str
, int & out_day
, int & out_month
, int & out_year
)
75 out_day
= 10*out_day
+ *(z
++) - '0';
80 out_month
= 10*out_month
+ *(z
++) - '0';
85 out_year
= 10*out_year
+ *(z
++) - '0';
90 date2str(String
& out_Str
, int day
, int month
, int year
)
92 char buf
[11] = "00.00.0000";
93 buf
[0] = static_cast<char>(day
/10 + '0');
94 buf
[1] = static_cast<char>(day
%10 + '0');
95 buf
[3] = static_cast<char>(month
/10 + '0');
96 buf
[4] = static_cast<char>(month
%10 + '0');
100 buf
[6] = static_cast<char>(year
/10 + '0');
101 buf
[7] = static_cast<char>(year
%10 + '0');
106 buf
[6] = static_cast<char>(year
/1000 + '0');
107 buf
[7] = static_cast<char>(year
%1000/100 + '0');
108 buf
[8] = static_cast<char>(year
%100/10 + '0');
109 buf
[9] = static_cast<char>(year
%10 + '0');
115 str2time(const char * str
, int & out_hour
, int & out_min
, int & out_sec
)
117 const char * z
= str
;
123 out_hour
= 10*out_hour
+ *(z
++) - '0';
128 out_min
= 10*out_min
+ *(z
++) - '0';
133 out_sec
= 10*out_sec
+ *(z
++) - '0';
138 time2str(String
& out_Str
, int hour
, int min
, int sec
)
140 char buf
[9] = "00:00:00";
141 buf
[0] = static_cast<char>(hour
/10 + '0');
142 buf
[1] = static_cast<char>(hour
%10 + '0');
143 buf
[3] = static_cast<char>(min
/10 + '0');
144 buf
[4] = static_cast<char>(min
%10 + '0');
145 buf
[6] = static_cast<char>(sec
/10 + '0');
146 buf
[7] = static_cast<char>(sec
%10 + '0');