Skip to content

Commit

Permalink
feat: Adds pt_BR locale
Browse files Browse the repository at this point in the history
  • Loading branch information
lennonjesus authored and rinukkusu committed Nov 27, 2018
1 parent 618bb23 commit 63acc96
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/simple_moment.dart
Expand Up @@ -3,9 +3,10 @@

library simple_moment;

export 'src/simple_moment_base.dart';
export 'src/identifier_position.dart';
export 'src/localedata.dart';
export 'src/locales/de.dart';
export 'src/locales/en.dart';
export 'src/locales/es.dart';
export 'src/identifier_position.dart';
export 'src/locales/pt_br.dart';
export 'src/simple_moment_base.dart';
27 changes: 27 additions & 0 deletions lib/src/locales/pt_br.dart
@@ -0,0 +1,27 @@
import '../identifier_position.dart';
import '../localedata.dart';

class LocalePtBr implements ILocaleData {
String get seconds => 'alguns segundos';

String get aMinute => 'um minuto';
String get minutes => '%i minutos';

String get anHour => 'uma hora';
String get hours => '%i horas';

String get aDay => 'um dia';
String get days => '%i dias';

String get aMonth => 'um mês';
String get months => '%i meses';

String get aYear => 'um ano';
String get years => '%i anos';

String get futureIdentifier => 'em';
String get pastIdentifier => 'atrás';

IdentifierPosition get futurePosition => IdentifierPosition.prepend;
IdentifierPosition get pastPosition => IdentifierPosition.append;
}
51 changes: 51 additions & 0 deletions test/simple_moment_pt_br_test.dart
@@ -0,0 +1,51 @@
// Copyright (c) 2016, rinukkusu. All rights reserved. Use of this source code
// is governed by a BSD-style license that can be found in the LICENSE file.

import 'package:simple_moment/simple_moment.dart';
import 'package:simple_moment/src/locales/pt_br.dart';
import 'package:test/test.dart';

void main() {
group('Um grupo de testes', () {
Moment.setLocaleGlobally(new LocalePtBr());

String dateString = "2016-12-31 02:33:01.565411";
DateTime date = DateTime.parse(dateString);

DateTime currentDate = DateTime.parse("2016-12-31 12:00:00");

setUp(() {});

test('static Moment.parse', () {
expect(Moment.parse(dateString).toString() == dateString, isTrue);
});

test('new Moment.fromDate', () {
expect(new Moment.fromDate(date).toString() == dateString, isTrue);
});

test('Moment.from(futuro)', () {
DateTime compareDate = DateTime.parse("2016-12-31 12:00:30");
expect(
new Moment.fromDate(currentDate).from(compareDate) ==
"em alguns segundos",
isTrue);
});

test('Moment.from(passado)', () {
DateTime compareDate = DateTime.parse("2016-12-31 11:59:30");
expect(
new Moment.fromDate(currentDate).from(compareDate) ==
"alguns segundos atrás",
isTrue);
});

test('Moment.from(menos de um segundo atrás)', () {
DateTime compareDate = DateTime.parse("2016-12-31 11:59:59.001");
expect(
new Moment.fromDate(currentDate).from(compareDate) ==
"alguns segundos atrás",
isTrue);
});
});
}

0 comments on commit 63acc96

Please sign in to comment.