Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
intranet-csv-import
Project
Project
Details
Activity
Releases
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
project-open
intranet-csv-import
Commits
dd584931
Commit
dd584931
authored
Feb 17, 2011
by
Frank Bergmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- added American date format
- fixed issue with single digit day-of-month or month
parent
ce55866e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
36 deletions
+50
-36
intranet-csv-import-procs.tcl
tcl/intranet-csv-import-procs.tcl
+50
-4
import-im_project.tcl
www/import-im_project.tcl
+0
-32
No files found.
tcl/intranet-csv-import-procs.tcl
View file @
dd584931
...
...
@@ -9,6 +9,52 @@ ad_library {
@author frank.bergmann@project-open.com
}
# ---------------------------------------------------------------------
# Aux functions
# ---------------------------------------------------------------------
ad_proc -public im_id_from_user_name
{
name
}
{
Checks for a user with the given name
}
{
set user_id
[
db_string uid
"
select min(user_id)
from users
where lower(trim(username)) = lower(trim(:name))
"
-default
""
]
if
{
""
==
$user
_id
}
{
set user_id
[
db_string uid
"
select min(person_id)
from persons
where lower(trim(im_name_from_user_id(person_id))) = lower(trim(:name))
"
-default
""
]
}
return
$user
_id
}
ad_proc -public im_csv_import_parser_date_european
{
arg
}
{
Parses a European date format like '08.06.2011' as the 8th of June, 2011
}
{
if
{[
regexp
{
^
(
.+
)
\.
(
.+
)
\.
(
....
)
$
}
$arg
match dom month year
]}
{
if
{
1 ==
[
string
length
$dom
]}
{
set dom
"0
$dom
"
}
if
{
1 ==
[
string
length
$month
]}
{
set dom
"0
$month
"
}
return
[
list
"
$year-$month-$dom
"
""
]
}
return
[
list
""
"Error parsing European date format '
$arg
': expected 'dd.mm.yyyy'"
]
}
ad_proc -public im_csv_import_parser_date_american
{
arg
}
{
Parses a American date format like '12/31/2011' as the 31st of December, 2011
}
{
if
{[
regexp
{
^
(
.+
)
\/
(
.+
)
\/
(
....
)
$
}
$arg
match month dom year
]}
{
if
{
1 ==
[
string
length
$dom
]}
{
set dom
"0
$dom
"
}
if
{
1 ==
[
string
length
$month
]}
{
set dom
"0
$month
"
}
return
[
list
"
$year-$month-$dom
"
""
]
}
return
[
list
""
"Error parsing American date format '
$arg
': expected 'dd.mm.yyyy'"
]
}
# ----------------------------------------------------------------------
#
...
...
@@ -27,9 +73,6 @@ ad_proc -public im_csv_import_label_from_object_type {
}
}
# ---------------------------------------------------------------------
# Available Fields per Object Type
# ---------------------------------------------------------------------
...
...
@@ -119,7 +162,8 @@ ad_proc -public im_csv_import_parsers {
im_project
{
set parsers
{
no_change
"No Change"
date_european
"European Data Parser (DD.MM.YYYY)"
date_european
"European Date Parser (DD.MM.YYYY)"
date_american
"American Date Parser (MM/DD/YYYY)"
}
}
default
{
...
...
@@ -157,11 +201,13 @@ ad_proc -public im_csv_import_guess_parser {
foreach val
$sample
_values
{
if
{
!
[
regexp
{
^
(
.+
)
\.
(
.+
)
\.
(
....
)
$
}
$val
match
]}
{
set date_european_p 0
}
if
{
!
[
regexp
{
^
(
.+
)
\/
(
.+
)
\/
(
....
)
$
}
$val
match
]}
{
set date_american_p 0
}
if
{
!
[
regexp
{
^
[
0-9
]
+$
}
$val
match
]}
{
set number_plain 0
}
}
if
{
$date
_european_p
}
{
return
"date_european"
}
if
{
$date
_american_p
}
{
return
"date_american"
}
if
{
$number
_plain_p
}
{
return
"number_plain"
}
return
""
...
...
www/import-im_project.tcl
View file @
dd584931
...
...
@@ -19,38 +19,6 @@ ad_page_contract {
parser:array
}
# ---------------------------------------------------------------------
# Aux functions
# ---------------------------------------------------------------------
ad_proc -public im_id_from_user_name
{
name
}
{
Checks for a user with the given name
}
{
set user_id
[
db_string uid
"
select min(user_id)
from users
where lower(trim(username)) = lower(trim(:name))
"
-default
""
]
if
{
""
==
$user
_id
}
{
set user_id
[
db_string uid
"
select min(person_id)
from persons
where lower(trim(im_name_from_user_id(person_id))) = lower(trim(:name))
"
-default
""
]
}
return
$user
_id
}
ad_proc -public im_csv_import_parser_date_european
{
arg
}
{
Parses a European date format like '08.06.2011' as the 8th of June, 2011
}
{
if
{[
regexp
{
^
(
.+
)
\.
(
.+
)
\.
(
....
)
$
}
$arg
match dom month year
]}
{
return
[
list
"
$year-$month-$dom
"
""
]
}
return
[
list
""
"Error parsing European date format '
$arg
': expected 'dd.mm.yyyy'"
]
}
# ---------------------------------------------------------------------
# Default & Security
# ---------------------------------------------------------------------
...
...
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