18 lines
453 B
TypeScript
18 lines
453 B
TypeScript
|
/**
|
||
|
* External dependencies
|
||
|
*/
|
||
|
import { WEEK } from '@woocommerce/data';
|
||
|
|
||
|
export function getStoreAgeInWeeks( adminInstallTimestamp: number ) {
|
||
|
if ( adminInstallTimestamp === 0 ) {
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
// Date.now() is ms since Unix epoch, adminInstallTimestamp is in
|
||
|
// seconds since Unix epoch.
|
||
|
const storeAgeInMs = Date.now() - adminInstallTimestamp * 1000;
|
||
|
const storeAgeInWeeks = Math.round( storeAgeInMs / WEEK );
|
||
|
|
||
|
return storeAgeInWeeks;
|
||
|
}
|