How to use the birthday function from chance

Find comprehensive JavaScript chance.birthday code examples handpicked from public code repositorys.

29
30
31
32
33
34
35
36
37
38
for (let i = 0; i < numPatients; i++) {
  const gender = Chance.gender();
  const omrsId = Chance.string({
    pool: REFAPP_OPENMRS_ID_CHARS,
  });
  const bday = Chance.birthday();

  // basic demographics
  const person = {
    names: [{
fork icon8
star icon16
watch icon5

+ 9 other calls in file

30
31
32
33
34
35
36
37
38
39
firstName: chance.first(),
lastName: chance.last(),
isAdmin: false,
email: emails.pop(),
gender: chance.gender(),
dob: chance.birthday({ string: true }),
occupation: chance.pickone(['Sales', 'Hospitality', 'Healthcare', 'Custodial', 'Accounting', 'Teaching', 'Law-Enforcement', 'Law', 'Finance', 'Engineering', 'Administration', 'Student', 'Other']),
incomeLevel: chance.weighted(['Under-$15,000', '$15,000-to-$24,999', '$25,000-to-$34,999', '$35,000-to-$49,999', '$50,000-to-$74,999', '$75,000-to-$99,999', '$100,000-to-$149,999', '$150,000-to-$199,999', '$200,000-and-over'], [11.6, 10.5, 10, 12.7, 16.7, 12.1, 14.1, 6.2, 6.1]),
ethnicity: chance.weighted(['White', 'Black', 'Hispanic', 'Asian', 'American-Indian/Alaska-Native', 'Hawaiian/Other-Pacific-Islander', 'Other'], [61, 12, 18, 6, 1, 0, 2]),
religion: chance.weighted(['Protestant', 'Catholic', 'Mormon', 'Judaism', 'Islam', 'Buddhism', 'Hinduism', 'Other', 'Unaffiliated'], [46.5, 20.8, 1.6, 1.9, 0.9, 0.7, 0.7, 3.5, 23.4]),
fork icon3
star icon12
watch icon6

+ 3 other calls in file

15
16
17
18
19
20
21
22
23
24
25
// Generate fake information
let firstname = faker.name.firstName();
let surname = faker.name.lastName();
let gender = 1; // 1: Female, 2: Male
let year = chance.year({ min: 1996, max: 1998 });
let dob = chance.birthday({ year: year });


nightmare
    .useragent(ua)
    .goto('http://m.facebook.com/reg')
fork icon4
star icon5
watch icon0

52
53
54
55
56
57
58
59
60
61
    break;
case 'birthday':
    n = hdr[k].arg;
    switch (n) {
        case '2':
            s += chance.birthday({
                string: true,
                american: false
            }).toCsv(CSV.delimiter);
            break;
fork icon2
star icon8
watch icon0

18
19
20
21
22
23
24
25
26
27
type: spec.label,
prefix: chance.prefix({gender: gender }),
first: chance.first({gender: gender}),
last: chance.last(),
age: chance.age(),
birthday: chance.birthday({string: true, american: true}),
gender: gender,
zip: chance.zip({plusfour: true}),
ssnFour: chance.ssn({ ssnFour: true }),
phone: chance.phone(),
fork icon0
star icon1
watch icon0

36
37
38
39
40
41
42
43
44
  return {
    kind: enumValues[getRandomInt(0, enumValues.length)],
    severity: getRandomInt(1, 11),
    amount: getRandomInt(1000, 10000000),
    bank: chance.pick(['ICICI', 'AXIS', 'SBI', 'HDFC', 'CITI']),
    openDate: chance.birthday(),
    defaults: getRandomInt(0, 10)
  };
};
fork icon0
star icon0
watch icon2

137
138
139
140
141
142
143
144
145
        postalCode: chance.zip(),
        country: chance.country(),
        gender: chance.gender(),
        orgTitle: chance.sentence({ words: 2 }),
        orgName: chance.domain(),
        birthday: chance.birthday({ string: true }),
        notes: 'Auto-generated contact'
    };
}
fork icon0
star icon0
watch icon0

+ 3 other calls in file