How do I get the manufacture date or age like what's shown in CoconutBattery using the terminal? I tried ioreg -cr AppleSmartBattery which gave a ManufacturerData (data, not date, but it was a date format) that's way too old to be correct for my computer. system_profiler SPPowerDataType doesn't show anything related to what I want.

EDIT: there is a ManufactureDate line in ioreg, but it's a 5 digit number – how do I decode that?


According to the Smart Battery Data spec, the ManufactureDate is as follows:

The date is packed in the following fashion: (year-1980) * 512 + month * 32 + day

More specifically, when the integer is converted to binary:

bits 0-4  -- day
bits 5-8 -- month
bits 9-15 -- years since 1980

Verifying this using my own machine, the integer derives to something like 2018-x-x, which makes sense given the age of my laptop.

( On Big Sur with my work laptop, however, the value is no longer a small integer, so I'm not sure how the latest OS is encoding the date information )

  • I think I'm not converting it right. Is there a bash/JS command that can do it? – ma1234 Apr 4 at 1:51
  • (I know the 5 digits are correct, having put the date in coconut battery into that formula) – ma1234 Apr 4 at 2:02
  • You can bitwise shift and mask in bash I believe. My bitwise operations are rusty but something like: echo $((1980+(0x7f & $d>>9)))-$((0x0f & ($d>>5)))-$((0x1f & $d)), where $d is the integer. Or you can just follow the packing formula -- take the integer, divide by 512, record the year, subtract it from the integer... – vykor Apr 4 at 16:40
  • That bash line gave me a syntax error, but it's ok since I was able to modify it to use in JavaScript. – ma1234 Apr 4 at 18:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .