## 阳历日期的推移 1. .next(days) 或 .nextDay(days) >
days(数字)
为推移的天数,正数为往后推,负数为往前推。返回推移后那天的阳历对象。 2. .next(days, onlyWorkday) >
days(数字)
为推移的天数,正数为往后推,负数为往前推。
onlyWorkday(布尔)
为true时仅按工作日推移(法定节假日和正常的周六、周日不算,节假日调休的按工作日计算)。返回推移后那天的阳历对象。 3. .nextHour(hours) >
hours(数字)
为推移的小时数,正数为往后推,负数为往前推。返回推移后的阳历对象。 4. .nextMonth(months) >
months(数字)
为推移的月数,正数为往后推,负数为往前推。返回推移后的阳历对象。 5. .nextYear(years) >
years(数字)
为推移的年数,正数为往后推,负数为往前推。返回推移后的阳历对象。 由于某些语言不支持同名方法,工作日推移的方法更改为
.nextWorkday(days)
。 ### 示例代码
javascript
java
csharp
php
python
go
var d = Solar.fromDate(new Date()); // 往后推两天,即后天 console.log(d.next(2)); // 往前推1天,即昨天 console.log(d.next(-1)); // 往后推2个工作日 console.log(d.next(2, true)); // 往前推1个工作日 console.log(d.next(-1, true));
Solar d = Solar.fromDate(new Date()); // 往后推两天,即后天 System.out.println(d.next(2)); // 往前推1天,即昨天 System.out.println(d.next(-1)); // 往后推2个工作日 System.out.println(d.next(2, true)); // 往前推1个工作日 System.out.println(d.next(-1, true));
Solar d = Solar.fromDate(new Date()); // 往后推两天,即后天 Console.WriteLine(d.next(2)); // 往前推1天,即昨天 Console.WriteLine(d.next(-1)); // 往后推2个工作日 Console.WriteLine(d.next(2, true)); // 往前推1个工作日 Console.WriteLine(d.next(-1, true));
$d = Solar::fromDate(new DateTime()); // 往后推两天,即后天 echo $d->next(2)."\n"; // 往前推1天,即昨天 echo $d->next(-1)."\n"; // 往后推2个工作日 echo $d->nextWorkday(2)."\n"; // 往前推1个工作日 echo $d->nextWorkday(-1)."\n";
d = Solar.fromDate(datetime.now()) # 往后推两天,即后天 print d.next(2) # 往前推1天,即昨天 print d.next(-1) # 往后推2个工作日 print d.nextWorkday(2) # 往前推1个工作日 print d.nextWorkday(-1)
d := calendar.NewSolarFromDate(time.Now()) // 往后推两天,即后天 fmt.Println(d.Next(2)) // 往前推1天,即昨天 fmt.Println(d.Next(-1))
### 输出