date.dart 406 B

1234567891011121314151617
  1. DateTime offsetDate(int type, int offset) {
  2. DateTime time = DateTime.now();
  3. DateTime next;
  4. if (type == 0) {
  5. next = time.add(Duration(days: offset));
  6. } else if (type == 1) {
  7. next = time.add(Duration(days: offset * 7));
  8. } else if (type == 2) {
  9. next = DateTime(time.year, time.month + offset, 1);
  10. } else {
  11. next = time.add(Duration(days: offset * 365 + 1));
  12. }
  13. return next;
  14. }