Skip to content

DateTime.parse() should throw an exception when incorrect values are passed #26858

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bizz84 opened this issue Jan 21, 2019 · 2 comments
Closed

Comments

@bizz84
Copy link

bizz84 commented Jan 21, 2019

Steps to Reproduce

Initialising a DateTime object with incorrect YYYY | MM | DD should throw an exception.

Currently, I can type in:

print(DateTime.parse("1999-02-31"));

And get the following log:

flutter: 1999-03-03 00:00:00.000

This is a known issue and there is a TODO in date_time.dart:

  // TODO(lrn): restrict incorrect values like  2003-02-29T50:70:80.
  // Or not, that may be a breaking change.

This is annoying as it means that Flutter doesn't provide a way to reliably validate dates that have been entered manually by the user.

Logs

[✓] Flutter (Channel stable, v1.0.0, on Mac OS X 10.13.6 17G65, locale en-GB)
    • Flutter version 1.0.0 at /Users/andrea/Documents/flutter
    • Framework revision 5391447fae (8 weeks ago), 2018-11-29 19:41:26 -0800
    • Engine revision 7375a0f414
    • Dart version 2.1.0 (build 2.1.0-dev.9.4 f9ebf21297)

[✓] Android toolchain - develop for Android devices (Android SDK 28.0.3)
    • Android SDK at /Users/andrea/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
    • All Android licenses accepted.

[!] iOS toolchain - develop for iOS devices (Xcode 10.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 10.1, Build version 10B61
    ✗ Verify that all connected devices have been paired with this computer in Xcode.
      If all devices have been paired, libimobiledevice and ideviceinstaller may require updating.
      To update with Brew, run:
        brew update
        brew uninstall --ignore-dependencies libimobiledevice
        brew uninstall --ignore-dependencies usbmuxd
        brew install --HEAD usbmuxd
        brew unlink usbmuxd
        brew link usbmuxd
        brew install --HEAD libimobiledevice
        brew install ideviceinstaller
    • ios-deploy 1.9.2
    ✗ ios-deploy out of date (1.9.4 is required). To upgrade with Brew:
        brew upgrade ios-deploy
    • CocoaPods version 1.6.0.beta.2

[✓] Android Studio (version 3.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 30.0.1
    • Dart plugin version 181.5656
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)

[✓] VS Code (version 1.27.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 2.19.0

[✓] Connected device (3 available)
    • Andrea iPhone 6 • d55e78eee17b7004891adf317eda2e03f756f81c • ios • iOS 12.1.2
    • iPhone 5s       • 2B7A7A09-F040-4D4E-8B48-E563C7944E09     • ios • iOS 12.1 (simulator)
    • iPhone XR       • 29AF675D-D8B2-41AC-A51F-DFE473A56040     • ios • iOS 12.1 (simulator)

! Doctor found issues in 1 category.
@zoechi
Copy link
Contributor

zoechi commented Jan 21, 2019

Duplicate of dart-lang/sdk#11189

@zoechi zoechi marked this as a duplicate of dart-lang/sdk#11189 Jan 21, 2019
@zoechi zoechi closed this as completed Jan 21, 2019
@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 31, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants