blob: 7c9b3954fc03ce8eec5c4a037cb069f1380cf67d [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';
void main() {
group('NSDate', () {
setUpAll(() {
// TODO(https://github.com/dart-lang/native/issues/1068): Remove this.
DynamicLibrary.open('test/objective_c.dylib');
});
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');
});
});
}