Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue102198-CtoT fixed #148

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/datetime/CtoT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ export const fromString = (
if (dateFrom.toUpperCase().indexOf("PM") !== -1) {
if (hour < 12) {
hour = hour + 12;
} else {
}
} else {
if (hour === 12) {
hour = 0;
}
}
Expand Down
8 changes: 7 additions & 1 deletion src/datetime/test/CtoT.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export const testCases1: Array<[string, Date]> = [
["12/17/2019 11:15:37 PM", new Date(2019, 11, 17, 23, 15, 37)],
["12/17/2019 11:15:37.000 AM", new Date(2019, 11, 17, 11, 15, 37, 0)],
["12/17/2019 11:15:37.000 PM", new Date(2019, 11, 17, 23, 15, 37, 0)],
["03/23/2023 12:09:43.000 PM", new Date(2023, 2, 23, 12, 9, 43, 0)],
["03/23/2023 12:09:43.000 AM", new Date(2023, 2, 23, 0, 9, 43, 0)],
["12172019 11:15 AM", EMPTY_DATE_VALUE],
["2172019 11:15 AM", EMPTY_DATE_VALUE],
["12172019 11:15:37 AM", EMPTY_DATE_VALUE],
Expand Down Expand Up @@ -59,6 +61,8 @@ export const testCases3: Array<[string, Date]> = [
["17/12/2019 11:15:37 PM", new Date(2019, 11, 17, 23, 15, 37)],
["17/12/2019 11:15:37.000 AM", new Date(2019, 11, 17, 11, 15, 37, 0)],
["17/12/2019 11:15:37.000 PM", new Date(2019, 11, 17, 23, 15, 37, 0)],
["30/03/2023 12:09:43.000 PM", new Date(2023, 2, 30, 12, 9, 43, 0)],
["30/03/2023 12:09:43.000 AM", new Date(2023, 2, 30, 0, 9, 43, 0)],
["17122019 11:15 AM", EMPTY_DATE_VALUE],
["1722019 11:15 AM", EMPTY_DATE_VALUE],
["17122019 11:15:37 AM", EMPTY_DATE_VALUE],
Expand Down Expand Up @@ -101,9 +105,11 @@ export const testCases5: Array<[string, Date]> = [
["2019/2/17 11:15 PM", new Date(2019, 1, 17, 23, 15)],
["2019/12/17 11:15:37 AM", new Date(2019, 11, 17, 11, 15, 37)],
["2019/12/17 11:15:37 PM", new Date(2019, 11, 17, 23, 15, 37)],
["2019/12/17 12:15:37 PM", new Date(2019, 11, 17, 0, 15, 37)],
["2019/12/17 12:15:37 PM", new Date(2019, 11, 17, 12, 15, 37)],
["2019/12/17 11:15:37.000 AM", new Date(2019, 11, 17, 11, 15, 37, 0)],
["2019/12/17 11:15:37.000 PM", new Date(2019, 11, 17, 23, 15, 37, 0)],
["2023/03/30 12:09:43.000 PM", new Date(2023, 2, 30, 12, 9, 43, 0)],
["2023/03/30 12:09:43.000 AM", new Date(2023, 2, 30, 0, 9, 43, 0)],
["20191217 11:15 AM", EMPTY_DATE_VALUE],
["2019217 11:15 AM", EMPTY_DATE_VALUE],
["20191217 11:15:37 AM", EMPTY_DATE_VALUE],
Expand Down