Skip to content

Instantly share code, notes, and snippets.

@bferg
Created January 20, 2015 19:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bferg/4b0ca36267dcbd57ba3d to your computer and use it in GitHub Desktop.
Save bferg/4b0ca36267dcbd57ba3d to your computer and use it in GitHub Desktop.
HMS-> and ->HMS time functions for PCalc based on the HP calculator functions of the same name. HMS format is HHH.MMSS, so e.g. 14.30305 in HMS converts to 14.5085 hours.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PCalc</key>
<dict>
<key>OS</key>
<string>iOS</string>
<key>UserFunctions</key>
<dict>
<key>Categories</key>
<dict>
<key>function.user.hms</key>
<dict>
<key>Functions</key>
<dict>
<key>function.user.hms.563162311</key>
<dict>
<key>Base</key>
<string>Decimal</string>
<key>Code</key>
<string>set r0 x; set r1 x; mod x 1; sub r1 x; set x r0; sub x r1; mul x 100; trn x; set r2 x; div x 60; trn x; add r1 x; mod r2 60; set x r0; mul x 100; mod x 1; mul x 100; set r3 x; mod r3 60; div x 60; trn x; add r2 x; set x r2; mod r2 60; div x 60 ; trn x; add r1 x; set x r3; div x 60; add x r2; div x 60; add x r1</string>
<key>Mode</key>
<string>All</string>
<key>Name</key>
<string>HMS-&gt;</string>
</dict>
<key>function.user.hms.563162312</key>
<dict>
<key>Base</key>
<string>Decimal</string>
<key>Code</key>
<string>set r0 x; trn r0; mod x 1; mul x 60; set r1 x; trn r1; sub x r1; mul x 60; div x 100; add x r1; div x 100; add x r0</string>
<key>Mode</key>
<string>All</string>
<key>Name</key>
<string>-&gt;HMS</string>
</dict>
</dict>
<key>Name</key>
<string>HMS</string>
</dict>
</dict>
</dict>
<key>Version</key>
<string>4.0</string>
</dict>
</dict>
</plist>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment