给出日期,返回该日期所在季度之前的季度最后一天的日期。例如
2020-04-25 => 2020-03-31
2020-06-25 => 2020-03-31
2020-09-25 => 2020-06-30
2020-10-25 => 2020-09-30
如果给定的日期在第一季度,则年份减去1
2020-03-25 => 2019-12-31
答案 0 :(得分:9)
<div class="email-div">
<i class="fas fa-user-shield"></i>
<input type="email" name="email" id="em-id" placeholder="Email" min="3" max="15"
spellcheck="false" required="true">
</div>
<div class="pass-div">
<i class="fas fa-lock"></i>
<input type="password" name="password" id="pass" placeholder="Password" min="8" max="32"
spellcheck="false" required="true">
</div>
<div class="btn-div">
<button class="btn" id="login-btn" v-on:click="login">LOGIN</button>
</div>
login: function() {
let email = document.getElementById('em-id').value
let password = document.getElementById('pass').value
if(email && password) {
console.log('email => ', + email) //gives output Nan
console.log('password => ' + password)
}
}
这至少需要Rakudo 2020.05。
答案 1 :(得分:4)
sub MAIN(Str $day) {
my Date $d = Date.new($day);
my Int $year = $d.year;
my Int $month = $d.month;
my Int $quarter = ($month/3).ceiling; # the quarter that this date falls
my @last-days = ('12-31', '03-31', '06-30', '09-30');
# if the given date is in the first quarter, then `$year` minus 1
$year-=1 if $quarter == 1;
say sprintf('%s-%s', $year, @last-days[$quarter-1]);
}
将上述代码另存为quarter.raku
,输出为:
$ raku quarter.raku 2020-03-25
2019-12-31
$ raku quarter.p6 2020-04-25
2020-03-31
$ raku quarter.p6 2020-06-25
2020-03-31
$ raku quarter.p6 2020-07-25
2020-06-30
$ raku quarter.p6 2020-08-25
2020-06-30
$ raku quarter.p6 2020-09-25
2020-06-30
$ raku quarter.p6 2020-10-25
2020-09-30