blob: 5dcd5029ef59765c5997cc6be95c83c12fdc9b8d [file] [log] [blame] [edit]
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// Objective C support is only available on mac.
@TestOn('mac-os')
library;
import 'dart:ffi';
import 'package:objective_c/objective_c.dart';
import 'package:test/test.dart';
import 'util.dart';
void main() {
group('NSDate', () {
setUpAll(() {
// TODO(https://github.com/dart-lang/native/issues/1068): Remove this.
DynamicLibrary.open(testDylib);
});
test('from DateTime', () {
final dartFirstAppeared = DateTime.utc(2011, 10, 10);
final nsDate = dartFirstAppeared.toNSDate();
expect(nsDate.description.toDartString(), '2011-10-10 00:00:00 +0000');
});
test('to DateTime', () {
final dartFirstAppeared = NSDate.dateWithTimeIntervalSince1970(
1318204800,
);
final dateTime = dartFirstAppeared.toDateTime();
expect(dateTime.toUtc().toString(), '2011-10-10 00:00:00.000Z');
});
});
}