Download wp-calypso/client/state/guided-tours/contexts/user-registration-time.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 644 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/state/guided-tours/contexts/user-registration-time.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/state/guided-tours/contexts/user-registration-time.js
-
curl -L -o user-registration-time.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/state/guided-tours/contexts/user-registration-time.js
644 Bytes
| import { getCurrentUser } from 'calypso/state/current-user/selectors'; | |
| export const WEEK_IN_MILLISECONDS = 7 * 1000 * 3600 * 24; | |
| /** | |
| * Returns a selector that tests if the user is newer than a given time | |
| * @param {number} age Number of milliseconds | |
| * @returns {Function} Selector function | |
| */ | |
| export const isUserNewerThan = ( age ) => ( state ) => { | |
| const user = getCurrentUser( state ); | |
| const registrationDate = user && Date.parse( user.date ); | |
| if ( ! registrationDate ) { | |
| return false; | |
| } | |
| const userAge = Date.now() - registrationDate; | |
| return userAge <= age; | |
| }; | |
| export const isNewUser = isUserNewerThan( WEEK_IN_MILLISECONDS ); | |