Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
T
Tour Travel Agency AGR
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dio Maulana
Tour Travel Agency AGR
Commits
b93f165c
Commit
b93f165c
authored
May 29, 2023
by
Dio Maulana
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
function replace date local dan international
parent
3adb16b3
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
96 additions
and
0 deletions
+96
-0
replace_date.dart
lib/helper/function/replace_date.dart
+96
-0
No files found.
lib/helper/function/replace_date.dart
0 → 100644
View file @
b93f165c
class
DateFormatCustom
{
static
String
monthLocal
(
String
month
)
{
switch
(
month
)
{
case
"01"
:
return
"Januari"
;
case
"02"
:
return
"Februari"
;
case
"03"
:
return
"Maret"
;
case
"04"
:
return
"April"
;
case
"05"
:
return
"Mei"
;
case
"06"
:
return
"Juni"
;
case
"07"
:
return
"Juli"
;
case
"08"
:
return
"Agustus"
;
case
"09"
:
return
"September"
;
case
"10"
:
return
"Oktober"
;
case
"11"
:
return
"November"
;
case
"12"
:
return
"Desember"
;
default
:
return
"Unknown"
;
}
}
static
String
monthInternational
(
String
monthLocal
)
{
switch
(
monthLocal
)
{
case
"Januari"
:
return
"01"
;
case
"Februari"
:
return
"02"
;
case
"Maret"
:
return
"03"
;
case
"April"
:
return
"04"
;
case
"Mei"
:
return
"05"
;
case
"Juni"
:
return
"06"
;
case
"Juli"
:
return
"07"
;
case
"Agustus"
:
return
"08"
;
case
"September"
:
return
"09"
;
case
"Oktober"
:
return
"10"
;
case
"November"
:
return
"11"
;
case
"Desember"
:
return
"12"
;
default
:
return
"Unknown"
;
}
}
}
String
dateLocal
(
String
dateTime
,
{
bool
fullDateTime
=
false
})
{
List
<
String
>
split
=
dateTime
.
split
(
" "
);
String
date
=
split
[
0
];
List
<
String
>
splitDate
=
date
.
split
(
"-"
);
String
year
=
splitDate
[
0
];
String
month
=
DateFormatCustom
.
monthLocal
(
splitDate
[
1
]);
String
tgl
=
splitDate
[
2
];
if
(
fullDateTime
)
{
return
"
$tgl
$month
$year
${split[1]}
"
;
}
else
{
return
"
$tgl
$month
$year
"
;
}
}
DateTime
toInternationFormat
(
String
dateLocal
,
{
bool
fullDateTime
=
false
})
{
List
<
String
>
splitDate
=
dateLocal
.
split
(
" "
);
String
?
time
;
if
(
fullDateTime
)
{
// 01 Mei 2023 00:00:00
time
=
splitDate
[
3
];
}
String
month
=
DateFormatCustom
.
monthInternational
(
splitDate
[
1
]);
String
year
=
splitDate
[
2
];
String
tgl
=
splitDate
[
0
];
DateTime
?
result
;
if
(
fullDateTime
)
{
result
=
DateTime
.
tryParse
(
"
$year
-
$month
-
${tgl}
T
$time
"
);
}
else
{
result
=
DateTime
.
tryParse
(
"
$year
-
$month
-
$tgl
"
);
}
return
result
!;
}
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