Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
a3de32ac
Kaydet (Commit)
a3de32ac
authored
Eki 28, 2015
tarafından
Matteo Casalin
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Rename (private) Date::init and reuse it
Change-Id: I3123876860cf6cce1e16c8f516f3d08fa7e15d83
üst
24c28ac7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
34 deletions
+21
-34
date.hxx
include/tools/date.hxx
+3
-3
tdate.cxx
tools/source/datetime/tdate.cxx
+18
-31
No files found.
include/tools/date.hxx
Dosyayı görüntüle @
a3de32ac
...
@@ -32,7 +32,7 @@ class TOOLS_DLLPUBLIC SAL_WARN_UNUSED Date
...
@@ -32,7 +32,7 @@ class TOOLS_DLLPUBLIC SAL_WARN_UNUSED Date
{
{
private
:
private
:
sal_uInt32
nDate
;
sal_uInt32
nDate
;
void
init
(
sal_uInt16
nDay
,
sal_uInt16
nMonth
,
sal_uInt16
nYear
)
void
setDateFromDMY
(
sal_uInt16
nDay
,
sal_uInt16
nMonth
,
sal_uInt16
nYear
)
{
nDate
=
(
sal_uInt32
(
nDay
%
100
)
)
+
{
nDate
=
(
sal_uInt32
(
nDay
%
100
)
)
+
(
(
sal_uInt32
(
nMonth
%
100
)
)
*
100
)
+
(
(
sal_uInt32
(
nMonth
%
100
)
)
*
100
)
+
(
(
sal_uInt32
(
nYear
%
10000
)
)
*
10000
);
}
(
(
sal_uInt32
(
nYear
%
10000
)
)
*
10000
);
}
...
@@ -56,11 +56,11 @@ public:
...
@@ -56,11 +56,11 @@ public:
Date
(
const
Date
&
rDate
)
Date
(
const
Date
&
rDate
)
{
nDate
=
rDate
.
nDate
;
}
{
nDate
=
rDate
.
nDate
;
}
Date
(
sal_uInt16
nDay
,
sal_uInt16
nMonth
,
sal_uInt16
nYear
)
Date
(
sal_uInt16
nDay
,
sal_uInt16
nMonth
,
sal_uInt16
nYear
)
{
init
(
nDay
,
nMonth
,
nYear
);
}
{
setDateFromDMY
(
nDay
,
nMonth
,
nYear
);
}
Date
(
const
css
::
util
::
Date
&
_rDate
)
Date
(
const
css
::
util
::
Date
&
_rDate
)
{
{
SAL_WARN_IF
(
_rDate
.
Year
<
0
,
"tools.datetime"
,
"Negative year in css::util::Date to ::Date conversion"
);
SAL_WARN_IF
(
_rDate
.
Year
<
0
,
"tools.datetime"
,
"Negative year in css::util::Date to ::Date conversion"
);
init
(
_rDate
.
Day
,
_rDate
.
Month
,
_rDate
.
Year
);
setDateFromDMY
(
_rDate
.
Day
,
_rDate
.
Month
,
_rDate
.
Year
);
}
}
Date
(
const
css
::
util
::
DateTime
&
_rDateTime
);
Date
(
const
css
::
util
::
DateTime
&
_rDateTime
);
...
...
tools/source/datetime/tdate.cxx
Dosyayı görüntüle @
a3de32ac
...
@@ -143,9 +143,7 @@ Date::Date( DateInitSystem )
...
@@ -143,9 +143,7 @@ Date::Date( DateInitSystem )
GetLocalTime
(
&
aDateTime
);
GetLocalTime
(
&
aDateTime
);
// Combine to date
// Combine to date
nDate
=
((
sal_uIntPtr
)
aDateTime
.
wDay
)
+
setDateFromDMY
(
aDateTime
.
wDay
,
aDateTime
.
wMonth
,
aDateTime
.
wYear
);
(((
sal_uIntPtr
)
aDateTime
.
wMonth
)
*
100
)
+
(((
sal_uIntPtr
)
aDateTime
.
wYear
)
*
10000
);
#else
#else
time_t
nTmpTime
;
time_t
nTmpTime
;
struct
tm
aTime
;
struct
tm
aTime
;
...
@@ -156,42 +154,33 @@ Date::Date( DateInitSystem )
...
@@ -156,42 +154,33 @@ Date::Date( DateInitSystem )
// compute date
// compute date
if
(
localtime_r
(
&
nTmpTime
,
&
aTime
)
)
if
(
localtime_r
(
&
nTmpTime
,
&
aTime
)
)
{
{
nDate
=
((
sal_uIntPtr
)
aTime
.
tm_mday
)
+
setDateFromDMY
(
static_cast
<
sal_uInt16
>
(
aTime
.
tm_mday
),
(((
sal_uIntPtr
)(
aTime
.
tm_mon
+
1
))
*
100
)
+
static_cast
<
sal_uInt16
>
(
aTime
.
tm_mon
+
1
),
(((
sal_uIntPtr
)(
aTime
.
tm_year
+
1900
))
*
10000
);
static_cast
<
sal_uInt16
>
(
aTime
.
tm_year
+
1900
)
);
}
}
else
else
nDate
=
1
+
100
+
(((
sal_uIntPtr
)
1900
)
*
10000
);
setDateFromDMY
(
1
,
100
,
1900
);
#endif
#endif
}
}
Date
::
Date
(
const
::
com
::
sun
::
star
::
util
::
DateTime
&
rDateTime
)
Date
::
Date
(
const
::
com
::
sun
::
star
::
util
::
DateTime
&
rDateTime
)
{
{
init
(
rDateTime
.
Day
,
rDateTime
.
Month
,
rDateTime
.
Year
);
setDateFromDMY
(
rDateTime
.
Day
,
rDateTime
.
Month
,
rDateTime
.
Year
);
}
}
void
Date
::
SetDay
(
sal_uInt16
nNewDay
)
void
Date
::
SetDay
(
sal_uInt16
nNewDay
)
{
{
sal_uIntPtr
nMonth
=
GetMonth
();
setDateFromDMY
(
nNewDay
,
GetMonth
(),
GetYear
()
);
sal_uIntPtr
nYear
=
GetYear
();
nDate
=
((
sal_uIntPtr
)(
nNewDay
%
100
))
+
(
nMonth
*
100
)
+
(
nYear
*
10000
);
}
}
void
Date
::
SetMonth
(
sal_uInt16
nNewMonth
)
void
Date
::
SetMonth
(
sal_uInt16
nNewMonth
)
{
{
sal_uIntPtr
nDay
=
GetDay
();
setDateFromDMY
(
GetDay
(),
nNewMonth
,
GetYear
()
);
sal_uIntPtr
nYear
=
GetYear
();
nDate
=
nDay
+
(((
sal_uIntPtr
)(
nNewMonth
%
100
))
*
100
)
+
(
nYear
*
10000
);
}
}
void
Date
::
SetYear
(
sal_uInt16
nNewYear
)
void
Date
::
SetYear
(
sal_uInt16
nNewYear
)
{
{
sal_uIntPtr
nDay
=
GetDay
();
setDateFromDMY
(
GetDay
(),
GetMonth
(),
nNewYear
);
sal_uIntPtr
nMonth
=
GetMonth
();
nDate
=
nDay
+
(
nMonth
*
100
)
+
(((
sal_uIntPtr
)(
nNewYear
%
10000
))
*
10000
);
}
}
DayOfWeek
Date
::
GetDayOfWeek
()
const
DayOfWeek
Date
::
GetDayOfWeek
()
const
...
@@ -364,9 +353,7 @@ bool Date::Normalize()
...
@@ -364,9 +353,7 @@ bool Date::Normalize()
if
(
!
Normalize
(
nDay
,
nMonth
,
nYear
))
if
(
!
Normalize
(
nDay
,
nMonth
,
nYear
))
return
false
;
return
false
;
SetDay
(
nDay
);
setDateFromDMY
(
nDay
,
nMonth
,
nYear
);
SetMonth
(
nMonth
);
SetYear
(
nYear
);
return
true
;
return
true
;
}
}
...
@@ -433,13 +420,13 @@ Date& Date::operator +=( long nDays )
...
@@ -433,13 +420,13 @@ Date& Date::operator +=( long nDays )
nTempDays
+=
nDays
;
nTempDays
+=
nDays
;
if
(
nTempDays
>
MAX_DAYS
)
if
(
nTempDays
>
MAX_DAYS
)
nDate
=
31
+
(
12
*
100
)
+
(((
sal_uIntPtr
)
9999
)
*
10000
);
setDateFromDMY
(
31
,
12
,
9999
);
else
if
(
nTempDays
<=
0
)
else
if
(
nTempDays
<=
0
)
nDate
=
1
+
100
;
setDateFromDMY
(
1
,
100
,
0
)
;
else
else
{
{
DaysToDate
(
nTempDays
,
nDay
,
nMonth
,
nYear
);
DaysToDate
(
nTempDays
,
nDay
,
nMonth
,
nYear
);
nDate
=
((
sal_uIntPtr
)
nDay
)
+
(((
sal_uIntPtr
)
nMonth
)
*
100
)
+
(((
sal_uIntPtr
)
nYear
)
*
10000
);
setDateFromDMY
(
nDay
,
nMonth
,
nYear
);
}
}
return
*
this
;
return
*
this
;
...
@@ -458,13 +445,13 @@ Date& Date::operator -=( long nDays )
...
@@ -458,13 +445,13 @@ Date& Date::operator -=( long nDays )
nTempDays
-=
nDays
;
nTempDays
-=
nDays
;
if
(
nTempDays
>
MAX_DAYS
)
if
(
nTempDays
>
MAX_DAYS
)
nDate
=
31
+
(
12
*
100
)
+
(((
sal_uIntPtr
)
9999
)
*
10000
);
setDateFromDMY
(
31
,
12
,
9999
);
else
if
(
nTempDays
<=
0
)
else
if
(
nTempDays
<=
0
)
nDate
=
1
+
100
;
setDateFromDMY
(
1
,
100
,
0
)
;
else
else
{
{
DaysToDate
(
nTempDays
,
nDay
,
nMonth
,
nYear
);
DaysToDate
(
nTempDays
,
nDay
,
nMonth
,
nYear
);
nDate
=
((
sal_uIntPtr
)
nDay
)
+
(((
sal_uIntPtr
)
nMonth
)
*
100
)
+
(((
sal_uIntPtr
)
nYear
)
*
10000
);
setDateFromDMY
(
nDay
,
nMonth
,
nYear
);
}
}
return
*
this
;
return
*
this
;
...
@@ -481,7 +468,7 @@ Date& Date::operator ++()
...
@@ -481,7 +468,7 @@ Date& Date::operator ++()
{
{
nTempDays
++
;
nTempDays
++
;
DaysToDate
(
nTempDays
,
nDay
,
nMonth
,
nYear
);
DaysToDate
(
nTempDays
,
nDay
,
nMonth
,
nYear
);
nDate
=
((
sal_uIntPtr
)
nDay
)
+
(((
sal_uIntPtr
)
nMonth
)
*
100
)
+
(((
sal_uIntPtr
)
nYear
)
*
10000
);
setDateFromDMY
(
nDay
,
nMonth
,
nYear
);
}
}
return
*
this
;
return
*
this
;
...
@@ -498,7 +485,7 @@ Date& Date::operator --()
...
@@ -498,7 +485,7 @@ Date& Date::operator --()
{
{
nTempDays
--
;
nTempDays
--
;
DaysToDate
(
nTempDays
,
nDay
,
nMonth
,
nYear
);
DaysToDate
(
nTempDays
,
nDay
,
nMonth
,
nYear
);
nDate
=
((
sal_uIntPtr
)
nDay
)
+
(((
sal_uIntPtr
)
nMonth
)
*
100
)
+
(((
sal_uIntPtr
)
nYear
)
*
10000
);
setDateFromDMY
(
nDay
,
nMonth
,
nYear
);
}
}
return
*
this
;
return
*
this
;
}
}
...
...
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