Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Drip
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
Issue 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
backup
Drip
Commits
e5418c32
Commit
e5418c32
authored
4 years ago
by
Julia Friesel
Committed by
Sofiya Tepikin
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix ordinal suffix for numbers greater than 10
parent
77908afd
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
components/chart/cycle-day-label.js
+3
-3
3 additions, 3 deletions
components/chart/cycle-day-label.js
components/helpers/home.js
+13
-7
13 additions, 7 deletions
components/helpers/home.js
components/home.js
+6
-6
6 additions, 6 deletions
components/home.js
with
22 additions
and
16 deletions
components/chart/cycle-day-label.js
+
3
−
3
View file @
e5418c32
...
...
@@ -7,7 +7,7 @@ import moment from 'moment'
import
AppText
from
'
../common/app-text
'
import
cycleModule
from
'
../../lib/cycle
'
import
{
dateEnding
}
from
'
../helpers/home
'
import
{
getOrdinalSuffix
}
from
'
../helpers/home
'
import
{
Containers
,
Typography
}
from
'
../../styles
'
const
CycleDayLabel
=
({
height
,
date
})
=>
{
...
...
@@ -18,13 +18,13 @@ const CycleDayLabel = ({ height, date }) => {
const
dateFormatting
=
isFirstDayOfMonth
?
'
MMM
'
:
'
D
'
const
shortDate
=
moment
(
date
,
"
YYYY-MM-DD
"
).
format
(
dateFormatting
)
const
ending
=
isFirstDayOfMonth
?
''
:
dateEnding
[
this
.
cycleDayNumber
]
||
dateEnding
[
'
default
'
]
''
:
getOrdinalSuffix
(
this
.
cycleDayNumber
)
const
cycleDayLabel
=
cycleDayNumber
?
cycleDayNumber
:
'
'
return
(
<
View
style
=
{[
styles
.
container
,
{
height
}]}
>
<
AppText
style
=
{
styles
.
textBold
}
>
{
cycleDayLabel
}
<
/AppText
>
<
View
style
=
{{
flexDirection
:
'
row
'
,
justifyContent
:
'
space-around
'
,
alignItems
:
'
center
'
}}
>
<
View
style
=
{{
flexDirection
:
'
row
'
,
justifyContent
:
'
space-around
'
,
alignItems
:
'
center
'
}}
>
<
AppText
style
=
{
styles
.
text
}
>
{
shortDate
}
<
/AppText
>
<
AppText
style
=
{
styles
.
textLight
}
>
{
ending
}
<
/AppText
>
<
/View
>
...
...
This diff is collapsed.
Click to expand it.
components/helpers/home.js
+
13
−
7
View file @
e5418c32
...
...
@@ -12,7 +12,7 @@ function getTimes(prediction) {
const
predictedBleedingStart
=
LocalDate
.
parse
(
prediction
[
0
][
0
])
/* the range of predicted bleeding days can be either 3 or 5 */
const
predictedBleedingEnd
=
LocalDate
.
parse
(
prediction
[
0
][
prediction
[
0
].
length
-
1
])
LocalDate
.
parse
(
prediction
[
0
][
prediction
[
0
].
length
-
1
])
const
daysToEnd
=
todayDate
.
until
(
predictedBleedingEnd
,
ChronoUnit
.
DAYS
)
return
{
todayDate
,
predictedBleedingStart
,
predictedBleedingEnd
,
daysToEnd
}
}
...
...
@@ -63,9 +63,15 @@ export function getBleedingPredictionRange(prediction) {
return
(
daysToEnd
===
0
?
'
0
'
:
`0 -
${
daysToEnd
}
`
)
}
export
const
dateEnding
=
{
'
1
'
:
'
st
'
,
'
2
'
:
'
nd
'
,
'
3
'
:
'
rd
'
,
'
default
'
:
'
th
'
}
export
function
getOrdinalSuffix
(
num
)
{
const
suffixes
=
{
1
:
'
st
'
,
2
:
'
nd
'
,
3
:
'
rd
'
,
default
:
'
th
'
}
const
numAsString
=
num
.
toString
()
const
lastNumber
=
numAsString
[
numAsString
.
length
-
1
]
return
suffixes
[
lastNumber
]
||
suffixes
.
default
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
components/home.js
+
6
−
6
View file @
e5418c32
...
...
@@ -13,7 +13,7 @@ import Button from './common/button'
import
cycleModule
from
'
../lib/cycle
'
import
{
getFertilityStatusForDay
}
from
'
../lib/sympto-adapter
'
import
{
determinePredictionText
,
dateEnding
}
from
'
./helpers/home
'
import
{
determinePredictionText
,
getOrdinalSuffix
}
from
'
./helpers/home
'
import
{
Colors
,
Fonts
,
Sizes
,
Spacing
}
from
'
../styles
'
import
{
home
as
labels
}
from
'
../i18n/en/labels
'
...
...
@@ -32,15 +32,15 @@ class Home extends Component {
this
.
todayDateString
=
today
.
toString
()
const
{
getCycleDayNumber
,
getPredictedMenses
}
=
cycleModule
()
this
.
cycleDayNumber
=
getCycleDayNumber
(
this
.
todayDateString
)
const
{
status
,
phase
,
statusText
}
=
const
{
status
,
phase
,
statusText
}
=
getFertilityStatusForDay
(
this
.
todayDateString
)
const
prediction
=
getPredictedMenses
()
this
.
cycleDayText
=
!
this
.
cycleDayNumber
?
labels
.
cycleDayNotEnoughInfo
:
`
${
this
.
cycleDayNumber
}${
dateEnding
[
this
.
cycleDayNumber
]
||
dateEnding
[
'
default
'
]
}
`
:
`
${
this
.
cycleDayNumber
}${
getOrdinalSuffix
(
this
.
cycleDayNumber
)
}
`
this
.
phase
=
phase
this
.
phaseText
=
!
phase
?
statusText
:
`
${
phase
}${
dateEnding
[
phase
]
||
dateEnding
[
'
default
'
]
}
`
:
`
${
phase
}${
getOrdinalSuffix
(
phase
)
}
`
this
.
prediction
=
determinePredictionText
(
prediction
)
this
.
status
=
status
this
.
statusText
=
statusText
...
...
@@ -149,13 +149,13 @@ const styles = StyleSheet.create({
})
const
mapStateToProps
=
(
state
)
=>
{
return
({
return
({
date
:
getDate
(
state
),
})
}
const
mapDispatchToProps
=
(
dispatch
)
=>
{
return
({
return
({
navigate
:
(
page
)
=>
dispatch
(
navigate
(
page
)),
setDate
:
(
date
)
=>
dispatch
(
setDate
(
date
)),
})
...
...
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