3 function createIdForTimestampString(timestamp) {
4 var hexSeconds = Math.floor(timestamp / 1000).toString(16);
6 while (hexSeconds.length < 8) {
7 hexSeconds = '0' + hexSeconds;
9 return hexSeconds + '0000000000000000';
12 function createIdForTimestamp(timestamp) {
13 return ObjectId(createIdForTimestampString(timestamp));
17 * Returns Date with start of the current month. This date can be shifted by `addMonths` months
18 * @param {Number} addMonths (can be negative) how many months should be added/subtracted to the start of the current month
20 function startOfUtcMonth(addMonths) {
21 const now = new Date();
22 return new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth() + addMonths, 1));