Skip to content

SML/NJ implementation of Date.fromTimeLocal differs from SML Basis Library Documentation #302

Description

@Skyb0rg007

Version

110.99.4 (Latest)

Operating System

  • Any
  • Linux
  • macOS
  • Windows
  • Other Unix

OS Version

No response

Processor

  • Any
  • Arm (using Rosetta)
  • PowerPC
  • Sparc
  • x86 (32-bit)
  • x86-64 (64-bit)
  • Other

System Component

Basis Library

Severity

Minor

Description

In the SML Basis Library, Date.fromTimeLocal has the following document string (emphasis mine):

fromTimeLocal t
fromTimeUniv t
These convert the (UTC) time t into a corresponding date. fromTimeLocal represents the date in the local time zone; it is the analogue of the ISO C function localtime. The returned date will have offset=NONE. fromTimeUniv returns the date in the UTC time zone; it is the analogue of the ISO C function gmtime. The returned date will have offset=SOME(0).

This is not how the function is implemented in SML/NJ:

fun fromTimeLocal t = let
  val offset = localOffsetForTime (timeToNs t)
  in
    tm2date (localTime t, SOME offset)
  end

fun tm2date (tm, offset) = DATE{
    (* ... *)
    offset = offset,
    (* ... *)
    }

Transcript

- Date.offset (Date.fromTimeLocal (Time.now ()));
val it = SOME (TIME {usec=18000000000}) : time option

Expected Behavior

- Date.offset (Date.fromTimeLocal (Time.now ()));
val it = NONE : time option

Steps to Reproduce

See transcript

Additional Information

This isn't a big deal, but incompatibilities should be documented, especially since the SML/NJ documentation page simply links to smlfamily.github.io.

Email address

skyler.soss@gmail.com

Metadata

Metadata

Assignees

Labels

basis-libproblem with Standard ML Basis librarybugSomething isn't workingfixed-in-110.99.5issues that will be fixed in the 110.99.5 version

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions