Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

[API Proposal]: DateTime/DateTimeOffset format

Đang mở
#644 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
35/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
fsharp
Lĩnh vực
api

Hướng nghiên cứu

Issue không nêu tệp hoặc test nào. Trước tiên, hãy tìm các triển khai TryParse và Parse hiện có của DateTime và DateTimeOffset, sau đó so sánh các định dạng hiện tại của chúng với các module InvariantCulture được đề xuất. Công việc được xem là hoàn tất khi hình dạng API và hành vi phân tích cú pháp của cả hai kiểu đã được thống nhất và triển khai, đồng thời các định dạng được đề xuất đã được xác thực.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Background and motivation

There is currently formats related to DateTime:

"yyyy-MM-ddTHH:mm:ss.fffZ"; "yyyy-MM-ddTHH:mm:ssZ"

and DateTimeOffset:

"yyyy-MM-ddTHH:mm:ss.fffK"; "yyyy-MM-ddTHH:mm:ssK"

These look related to ISO 8601. See the roundtrip format in:

https://learn.microsoft.com/en-us/dotnet/standard/base-types/standard-date-and-time-format-strings

And the page on the standard on wikipedia:
https://en.wikipedia.org/wiki/ISO_8601

API Proposal

Modules in the Extensions.InvariantCulture namespace named DateTime and DateTimeOffset with related functions. Move the implementation of TryParse and Parse of DateTime and DateTimeOffset to these modules.

namespace FSharpPlus.Extensions.InvariantCulture

[<RequireQualifiedAccess>]
module DateTime =
     let tryParse (x:string) =
        match DateTime.TryParseExact (x, [|"yyyy-MM-ddTHH:mm:ss.fffZ"; "yyyy-MM-ddTHH:mm:ssZ"|], null, DateTimeStyles.RoundtripKind) with
        | true, x -> Some x
        | _ ->
            match DateTime.TryParse (x, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal) with
            | true, x -> Some x
            | _ -> None
API Usage
open FSharpPlus.Extensions
let parsed = InvariantCulture.DateTime.tryParse stringFromTheInternet
Alternative Designs

No response

Risks

Probably little risk

Are you willing to help with a proof-of-concept (as PR in that or a separate repo) first and as pull-request later on?

Yes, please assign this issue to me.

Ngôn ngữ chính
F#
Star
942
Fork
105
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của fsprojects/FSharpPlus

Tất cả issue của fsprojects/FSharpPlus

Issue tương tự

Thêm issue về Backend & API Design

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.