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

Provided Time as a List of Time Components #22

Open
sshaw opened this issue Jun 1, 2019 · 7 comments
Open

Provided Time as a List of Time Components #22

sshaw opened this issue Jun 1, 2019 · 7 comments

Comments

@sshaw
Copy link

sshaw commented Jun 1, 2019

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.

@atheriel
Copy link
Owner

atheriel commented Jun 3, 2019

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.

@sshaw
Copy link
Author

sshaw commented Jun 3, 2019

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.

@atheriel
Copy link
Owner

atheriel commented Jun 3, 2019

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?

@sshaw
Copy link
Author

sshaw commented Jun 3, 2019

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.

@atheriel
Copy link
Owner

atheriel commented Jun 3, 2019

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.

@sshaw
Copy link
Author

sshaw commented Jun 3, 2019

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))
               ",")))

@atheriel
Copy link
Owner

atheriel commented Jun 4, 2019

Thanks, that's very helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants