Coder Social home page Coder Social logo

date_format's Introduction

date_format

A simple API to format dates.

Usage

Use formatDate function to format a DateTime object.

print(formatDate(DateTime(1989, 02, 21), [yyyy, '-', mm, '-', dd]));

Output:

1989-02-21

Long month names

print(formatDate(DateTime(1989, 2, 21), [yy, '-', M, '-', d]));

Output:

89-feb-21

Time parts

print(formatDate(
      DateTime(1989, 02, 1, 15, 40, 10), [HH, ':', nn, ':', ss]));

Output:

15:40:10

Timezone

print(formatDate(
      DateTime(1989, 02, 1, 15, 40, 10), [HH, ':', nn, ':', ss, z]));

Output:

15:40:10+0100

date_format's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

date_format's Issues

Noon shows up as "0PM", but should be "12PM"

I'm formatting a DateTime object that shows up in Linux as 'Mon Nov 5 12:00:00 EST 2018'. In my app, I'm formatting it with '[h,am]', and it outputs "0PM", when I would expect '12PM'. In the code, I see writing AM or PM based on: date.hour date.hour < 12 ? 'AM' : 'PM'. Maybe this should be "<="? Or, should the outputting of the hour not be a plain "hour % 12", but if hour%12==0, then add 12? I suspect this would also fix midnight coming out as "0AM". Thanks.

string with NUlL value

Some API endpoints will return a data string with the value NULL because it is allowed in database.
In that case fluter will throw an error.

Enhancement: Any possible of adding relative formatting

Not sure how this would work but I need relative formatting with a fall back to normal date formatting.

Example:
Today @ 11:15 AM which would fall back to 11/23/2022 @ 11:15 AM if that is not today. Same for yesterday and tomorrow.

You want FrenchDateLocale : voilà !

there is more than to integrate :

`import 'package:date_format/date_format.dart';

class FrenchDateLocale implements DateLocale {
const FrenchDateLocale();

final List monthsShort = const [
'Jan',
'Féb',
'Mar',
'Avr',
'Mai',
'Juin',
'Juil',
'Aoû',
'Sep',
'Oct',
'Nov',
'Déc'
];

final List monthsLong = const [
'Janvier',
'Février',
'Mars',
'Avril',
'Mai',
'Juin',
'Juillet',
'Août',
'Septembre',
'Octobre',
'Novembre',
'Décembre'
];

final List daysShort = const [
'Lun',
'Mar',
'Mer',
'Jeu',
'Ven',
'Sam',
'Dim'
];

final List daysLong = const [
'Lundì',
'Mardì',
'Mercredì',
'Jeudi',
'Vendredi',
'Samedi',
'Dimanche'
];

//don’t exists in France, we are in 24 hours per day
@OverRide
String get am => "AM";

@OverRide
String get pm => "PM";
}`

about the weekday, we cannot get the day 'Friday' .[version 1.0.8]

I don't know whether there is something wrong with this package when using such code:
formDate(DateTime(DateTime.now().weekday),[DD])

things like that:
formDate(DateTime(5),[DD]), the result is Saturday;
formDate(DateTime(6),[DD]), the result is Sunday;
formDate(DateTime(7),[DD]), the result is Monday;
and, I tried the argument from 1 to 7, there is no Friday.

when import 'package:date_format/date_format.dart Locale Error

when import 'package:date_format/date_format.dart'; In the use of internationalization Locale unrecognized
supportedLocales: [
const Locale('en', 'US'), // English
const Locale('he', 'IL'), // Hebrew
// ... other locales the app supports
],
Can't speak English Translation software written

Help needed

Hello @tejainece,

Sorry to come here to send you a message but you seem to be active on this repository.

I really need updates on the Pull Request for Jaguar ORM for Flutter !

I would appreciate an update very much,
Thank you in advance,

Alex

Allow the format be specified as a single string

The current formatting method is a little painful

  var _message = '${formatDate(DateTime.now(), [
        'yy',
        '-',
        'M',
        '-',
        'd',
        ' ',
        'h',
        ':',
        'm',
        ':',
        's'
      ])} $message}';

It would be nicer if you could do:

print(${formatDate(DateTime.now(), 'yy-M-d h:m:s')}');

Locale

Didn't find a way to replace the months name. There is any way?

reamde examples are incorrect

All of the examples on you readme page are incorrect as you have forgotten to quote the value:

print(formatDate(DateTime(1989, 02, 21), [yyyy, '-', mm, '-', dd]));

should read

print(formatDate(DateTime(1989, 02, 21), ['yyyy', '-', 'mm', '-', 'dd]'));

Thur error?

final List daysShort = const [
'Mon',
'Tue',
'Wed',
'Thur',
'Fri',
'Sat',
'Sun'
];

error: request time Thur, 03 Nov 2022 03:02:24 GMT not follow RFC822 spec
Thur -> Thu ?

How to use Localization support?

Hi,

Thanks for this library. I see in the latest commit which says "Locale/internationailization support".

Can you please tell me how can I use it? I want to use Urdu (ur) Locale.

Thanks,
Saeed

Flutter 1.12.13+hotfix.5 error

when i upgrade flutter to Flutter 1.12.13+hotfix.5

error: The name 'Locale' is defined in the libraries 'dart:ui' and 'package:date_format/src/locale/locale.dart'. (ambiguous_export at [itest] lib/common/index_all.dart:48)

French locale is not exported

The newly added French locale file is not imported along with other locales in locale.dart file. Please provide a fix to this

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.