Nashorn: Difference between revisions
Jump to navigation
Jump to search
(7 intermediate revisions by the same user not shown) | |||
Line 24: | Line 24: | ||
dobOf18YearsOld = todayDate.subtract(AGE_18, 'years'), | dobOf18YearsOld = todayDate.subtract(AGE_18, 'years'), | ||
nricOf18YearsOld = dobOf18YearsOld.format(NRIC_FORMAT), | nricOf18YearsOld = dobOf18YearsOld.format(NRIC_FORMAT), | ||
aDayEarly18Years = dobOf18YearsOld. | aDayEarly18Years = dobOf18YearsOld.add(DAY_1, 'days'), | ||
nricOfDayEarly18 = aDayEarly18Years.format(NRIC_FORMAT); | nricOfDayEarly18 = aDayEarly18Years.format(NRIC_FORMAT); | ||
Line 44: | Line 44: | ||
todayDate = moment(), | todayDate = moment(), | ||
NRIC_FORMAT = 'YYMMDD-[01]-[0001]', | NRIC_FORMAT = 'YYMMDD-[01]-[0001]', | ||
dobOf56YearsOld | dobOf56YearsOld = todayDate.subtract(AGE_56, 'years'), | ||
nricOf56YearsOld | nricOf56YearsOld = dobOf56YearsOld.format(NRIC_FORMAT), | ||
aDayEarly56Years = dobOf56YearsOld. | aDayEarly56Years = dobOf56YearsOld.add(DAY_1, 'days'), | ||
nricOfDayEarly56 = aDayEarly56Years.format(NRIC_FORMAT); | nricOfDayEarly56 = aDayEarly56Years.format(NRIC_FORMAT); | ||
Line 65: | Line 65: | ||
<source lang="bash"> | <source lang="bash"> | ||
jjs -v | jjs -v | ||
# load('./src/main/resources/javascript/momentScript.js'); | |||
load('https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.4/moment.min.js'); | load('https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.4/moment.min.js'); | ||
</source> | </source> | ||
Line 82: | Line 83: | ||
load('./printNricOf56YearsMan.js'); | load('./printNricOf56YearsMan.js'); | ||
printNricOf56YearsMan(); | printNricOf56YearsMan(); | ||
</source> | |||
|} | |||
==NRIC By Life Asia Age== | |||
{| | |||
| valign="top" colspan="2" | | |||
mkdir -p ~/Documents/nashorn-playground | |||
cd ~/Documents/nashorn-playground | |||
|- | |||
| colspan="2" | | |||
---- | |||
|- | |||
| valign="top" | | |||
<source lang="js"> | |||
cat <<'EOF' >> ~/Documents/nashorn-playground/printNricByLifeAsia18YearsMan.js | |||
function printNricByLifeAsia18YearsMan(message) { | |||
var DAY_1 = 1, | |||
AGE_18 = 18, | |||
todayDate = moment(), | |||
LIFE_ASIA_AGE = AGE_18 - 1, | |||
NRIC_FORMAT = 'YYMMDD-[01]-[0001]', | |||
dobOf18YearsOld = todayDate.subtract(LIFE_ASIA_AGE, 'years'), | |||
nricOf18YearsOld = dobOf18YearsOld.format(NRIC_FORMAT), | |||
aDayEarly18Years = dobOf18YearsOld.add(DAY_1, 'days'), | |||
nricOfDayEarly18 = aDayEarly18Years.format(NRIC_FORMAT); | |||
message = 'NRIC of' | |||
+ '\n18 Years old: ' + nricOf18YearsOld | |||
+ '\n17 Years old: ' + nricOfDayEarly18; | |||
print(message); | |||
} | |||
EOF | |||
</source> | |||
| valign="top" | | |||
<source lang="js"> | |||
cat <<'EOF' >> ~/Documents/nashorn-playground/printNricByLifeAsia56YearsMan.js | |||
function printNricByLifeAsia56YearsMan(message) { | |||
var DAY_1 = 1, | |||
AGE_56 = 56, | |||
todayDate = moment(), | |||
LIFE_ASIA_AGE = AGE_56 - 1, | |||
NRIC_FORMAT = 'YYMMDD-[01]-[0001]', | |||
dobOf56YearsOld = todayDate.subtract(LIFE_ASIA_AGE, 'years'), | |||
nricOf56YearsOld = dobOf56YearsOld.format(NRIC_FORMAT), | |||
aDayEarly56Years = dobOf56YearsOld.add(DAY_1, 'days'), | |||
nricOfDayEarly56 = aDayEarly56Years.format(NRIC_FORMAT); | |||
message = 'NRIC of' | |||
+ '\n56 Years old: ' + nricOf56YearsOld | |||
+ '\n55 Years old: ' + nricOfDayEarly56; | |||
print(message); | |||
} | |||
EOF | |||
</source> | |||
|- | |||
| colspan="2" | | |||
---- | |||
|- | |||
| valign="top" colspan="2" | | |||
<source lang="bash"> | |||
jjs -v | |||
# load('./src/main/resources/javascript/momentScript.js'); | |||
load('https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.4/moment.min.js'); | |||
</source> | |||
|- | |||
| colspan="2" | | |||
---- | |||
|- | |||
| valign="top" | | |||
<source lang="bash"> | |||
load('./printNricByLifeAsia18YearsMan.js'); | |||
printNricByLifeAsia18YearsMan(); | |||
</source> | |||
| valign="top" | | |||
<source lang="bash"> | |||
load('./printNricByLifeAsia56YearsMan.js'); | |||
printNricByLifeAsia56YearsMan(); | |||
</source> | </source> | ||
Line 101: | Line 187: | ||
|- | |- | ||
| valign="top" | | | valign="top" | | ||
* [[JavaScript Proprietary Library Example]] | * [[JavaScript Proprietary Library Example]] | ||
* [[JavaScript Ali Express Discounted Cart]] | * [[JavaScript Ali Express Discounted Cart]] | ||
Line 114: | Line 199: | ||
| valign="top" | | | valign="top" | | ||
* [[How to build Proprietary JavaScript Library]] | |||
* [[Postman Script]] | |||
| valign="top" | | | valign="top" | | ||
|} | |} |
Latest revision as of 05:51, 25 January 2024
sudo apt install openjdk-8-jdk update-alternatives --query jjs sudo update-alternatives --config jjs jjs -v
NRIC By Age
mkdir -p ~/Documents/nashorn-playground cd ~/Documents/nashorn-playground | |
| |
cat <<'EOF' >> ~/Documents/nashorn-playground/printNricOf18YearsMan.js
function printNricOf18YearsMan(message) {
var DAY_1 = 1,
AGE_18 = 18,
todayDate = moment(),
NRIC_FORMAT = 'YYMMDD-[01]-[0001]',
dobOf18YearsOld = todayDate.subtract(AGE_18, 'years'),
nricOf18YearsOld = dobOf18YearsOld.format(NRIC_FORMAT),
aDayEarly18Years = dobOf18YearsOld.add(DAY_1, 'days'),
nricOfDayEarly18 = aDayEarly18Years.format(NRIC_FORMAT);
message = 'NRIC of'
+ '\n18 Years old: ' + nricOf18YearsOld
+ '\n17 Years old: ' + nricOfDayEarly18;
print(message);
}
EOF
|
cat <<'EOF' >> ~/Documents/nashorn-playground/printNricOf56YearsMan.js
function printNricOf56YearsMan(message) {
var DAY_1 = 1,
AGE_56 = 56,
todayDate = moment(),
NRIC_FORMAT = 'YYMMDD-[01]-[0001]',
dobOf56YearsOld = todayDate.subtract(AGE_56, 'years'),
nricOf56YearsOld = dobOf56YearsOld.format(NRIC_FORMAT),
aDayEarly56Years = dobOf56YearsOld.add(DAY_1, 'days'),
nricOfDayEarly56 = aDayEarly56Years.format(NRIC_FORMAT);
message = 'NRIC of'
+ '\n56 Years old: ' + nricOf56YearsOld
+ '\n55 Years old: ' + nricOfDayEarly56;
print(message);
}
EOF
|
| |
jjs -v
# load('./src/main/resources/javascript/momentScript.js');
load('https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.4/moment.min.js');
| |
| |
load('./printNricOf18YearsMan.js');
printNricOf18YearsMan();
|
load('./printNricOf56YearsMan.js');
printNricOf56YearsMan();
|
NRIC By Life Asia Age
mkdir -p ~/Documents/nashorn-playground cd ~/Documents/nashorn-playground | |
| |
cat <<'EOF' >> ~/Documents/nashorn-playground/printNricByLifeAsia18YearsMan.js
function printNricByLifeAsia18YearsMan(message) {
var DAY_1 = 1,
AGE_18 = 18,
todayDate = moment(),
LIFE_ASIA_AGE = AGE_18 - 1,
NRIC_FORMAT = 'YYMMDD-[01]-[0001]',
dobOf18YearsOld = todayDate.subtract(LIFE_ASIA_AGE, 'years'),
nricOf18YearsOld = dobOf18YearsOld.format(NRIC_FORMAT),
aDayEarly18Years = dobOf18YearsOld.add(DAY_1, 'days'),
nricOfDayEarly18 = aDayEarly18Years.format(NRIC_FORMAT);
message = 'NRIC of'
+ '\n18 Years old: ' + nricOf18YearsOld
+ '\n17 Years old: ' + nricOfDayEarly18;
print(message);
}
EOF
|
cat <<'EOF' >> ~/Documents/nashorn-playground/printNricByLifeAsia56YearsMan.js
function printNricByLifeAsia56YearsMan(message) {
var DAY_1 = 1,
AGE_56 = 56,
todayDate = moment(),
LIFE_ASIA_AGE = AGE_56 - 1,
NRIC_FORMAT = 'YYMMDD-[01]-[0001]',
dobOf56YearsOld = todayDate.subtract(LIFE_ASIA_AGE, 'years'),
nricOf56YearsOld = dobOf56YearsOld.format(NRIC_FORMAT),
aDayEarly56Years = dobOf56YearsOld.add(DAY_1, 'days'),
nricOfDayEarly56 = aDayEarly56Years.format(NRIC_FORMAT);
message = 'NRIC of'
+ '\n56 Years old: ' + nricOf56YearsOld
+ '\n55 Years old: ' + nricOfDayEarly56;
print(message);
}
EOF
|
| |
jjs -v
# load('./src/main/resources/javascript/momentScript.js');
load('https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.4/moment.min.js');
| |
| |
load('./printNricByLifeAsia18YearsMan.js');
printNricByLifeAsia18YearsMan();
|
load('./printNricByLifeAsia56YearsMan.js');
printNricByLifeAsia56YearsMan();
|
References
|
||
| ||