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

Convenience macro for hour-minute-second quantities #684

Open
schtandard opened this issue Aug 16, 2023 · 4 comments
Open

Convenience macro for hour-minute-second quantities #684

schtandard opened this issue Aug 16, 2023 · 4 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@schtandard
Copy link

A convenience macro for typesetting time quantities consisting of hours minutes and seconds would be nice, analogous to the \ang macro. For example \hms{3;22;15.3} could output 3 h 22 min 15.3 s, \hms{1.5} 1.5 h and \hms{;15;} 15 min.

@josephwright
Copy link
Owner

#70?

@schtandard
Copy link
Author

schtandard commented Aug 16, 2023

Not quite, though they are related. I am asking for a clone of \ang for typesetting time. Basically something equivalent to

\NewDocumentCommand\hms{ O{} m }{%
  \ang[%
    angle-symbol-degree = \hour,
    angle-symbol-minute = \minute,
    angle-symbol-second = \second,
    number-angle-product = \,,
    angle-separator = ~, % Not sure about this setting.
    #1,
    ]{#2}%
}

though I would expect it to use the value of quantity-product instead of a separate number-angle-product, at least by default.

This would almost give what #70 is asking for by way of (the analog of) angle-mode = arc: With that setting \hms{1.5} would give 1 h 30 min (well, I am getting a trailing 0 s, not sure if this is by design). Getting rid of the min with the preceding space could be achieved by tweaking the settings in a somewhat unorthodox way (angle-symbol-degree = \,\hour, angle-symbol-minute = , number-angle-product = ,) which is fine, I think. The format 1:30 h would not quite be possible (the issue being the trailing h).

One could of course go even further and consider an interface for generating arbitrary commands that generate cascading quantities like this, with arbitrary factors between them. This would enable users to create e.g. a command like above but including days as an additional level (\dhms{2;5;13} giving 2 d 5 h 13 min or 2.217 d depending on the settings) or one for other non-decimal units like feet and inches or stones and pounds and the like. This would require much more care and work to design an appropriate interface, though, and I don't know if the use-cases justifies this. Also, most of them would probably arise from not using SI units, which is not really what this package is about, I guess.

@josephwright josephwright self-assigned this Aug 17, 2023
@josephwright josephwright added the enhancement New feature or request label Aug 17, 2023
@josephwright josephwright added this to the v3.4 milestone Aug 17, 2023
@josephwright josephwright changed the title Feature Request: Convenience macro for hour-minute-second quantities Convenience macro for hour-minute-second quantities Aug 17, 2023
@josephwright
Copy link
Owner

I think this would be a separate sub-module from angles, or perhaps done the same way as products, etc. (core code the same, different interfaces). I guess the main question for me is the document command: I will look to see what \hms is used.

@josephwright
Copy link
Owner

I don't see \hms in use in TL, so this looks safe.

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

No branches or pull requests

2 participants