org-clock-csv
org-clock-csv copied to clipboard
Provided Time as a List of Time Components
Currently a string is provided but this format may not be what those that define custom format functions want. Instead of having one parse the time string it's better to provide a list of (YYYY MM DD HH MM)
and let them construct desired format.
Although this is possible, this would seriously increase the complexity for those format functions, which is why the current approach was chosen.
I had always imagined that these CSV files would be consumed by external tools, so I'm inclined to think that those tools should handle parsing timestamp strings into their own representation, instead of pushing this complexity into the format function. Is that unreasonable?
To clarify this expectation, we could explicitly state the format of the timestamp (e.g. ISO 8601) in the documentation to make parsing easier.
I had always imagined that these CSV files would be consumed by external tools, so I'm inclined to think that those tools should handle parsing timestamp strings into their own representation
Yes but those tools are often systems that do not accept ISO 8601 dates and are of the user's control
Although this is possible, this would seriously increase the complexity for those format functions, which is why the current approach was chosen... we could explicitly state the format of the timestamp (e.g. ISO 8601) in the documentation to make parsing easier.
You can always provide both. Really I think it's easier to get some items out of a list and reformat it than it is to pick apart an 8601 string via regex or substring then reformat it.
Yes but those tools are often systems that do not accept ISO 8601 dates and are of the user's control
Can you give an example? What problem are you encountering?
Can you give an example? What problem are you encountering?
I need to import time into a system that does not accept ISO 8601 dates. Therefore I need to parse the current date/time string provided to org-clock-csv-row-fmt
.
Let me be more clear: what, exactly, is the system that (1) does not accept these dates but (2) accepts the other fields without issue.
Wow, there are certainly 100s. But................. here's one example: https://support.toggl.com/import-and-export/csv-import/editing-and-uploading-a-csv-file
Code:
(defun toggl-format (plist)
(let* ((start-time (concat (cadr (split-string (plist-get plist ':start))) ":00"))
(duration (concat (plist-get plist ':duration) ":00")))
(when (string-match-p "^[0-9]:" duration)
(setq duration (concat "0" duration)))
(mapconcat #'identity
(list
user-mail-address
"Some Project"
"Some other thing...."
(org-clock-csv--escape (plist-get plist ':task))
(car (split-string (plist-get plist ':start)))
start-time
duration
(org-clock-csv--escape (s-join org-clock-csv-headline-separator (plist-get plist ':parents)))
(plist-get plist ':tags))
",")))
Thanks, that's very helpful.