I have defined the following user units (psuedo-code):
unix_days = unix_seconds/86400; nasa_seconds = unix_seconds - 946728000;
This allows me to directly convert unix_seconds to unix_days or convert unix_seconds to nasa_seconds .
However, I cannot directly convert unix_days back to unix_seconds without writing another formula.
Similarly, I cannot convert nasa_seconds to unix_days without writing additional formulas.
Is there a smart routine or Perl package that allows me to do this without writing additional functions? In particular, a custom block is a conversion package that:
May divine conversion function conversion units. For example, the opposite of f(x)=x/86400 is g(y)=y*86400 .
You can apply transitivity as needed. For example, if unix_seconds = nasa_seconds + 946728000 (functional inverse) and unix_days = unix_seconds/86400 , we can combine them to convert directly from nasa_seconds to unix_days .
I am fine with writing conversion formulas in unusual ways, if necessary. For example, in Celsius to Fahrenheit you can write:
C to F: *1.8 +32
This form is easy to invert: just follow the steps back and vice versa:
F to C: -32 /1.8
Is there such a thing?
source share