Git Product home page Git Product logo

ztimestamp's Introduction

ZTimestamp

CI

I am ZTimestamp.

I am a Magnitude.

I represent a point in time, a combination of a date and a time.

I am an alternative for DateAndTime and TimeStamp.
I have nanosecond precision and live in the UTC/GMT/Zulu timezone.
I use ISO/International conventions and protocols only.
I support some essential arithmetic.

I have an efficient internal representation:

jnd - the julian day number <SmallInteger>
ns - the number of nanoseconds since midnight, the beginning of the day <SmallInteger>

Examples:

ZTimestamp now.
ZTimestamp fromString: '1969-07-20T20:17:40Z'.
ZTimestamp fromString: '2021-11-17T09:05:12.94603Z'.

There is some compatibility with existing, standard Chronology objects. I correctly parse representations with a timezone designator and can print a representation in arbitrary timezone offsets.

The key idea of ZTimestamp is to store and work with timestamps in UTC internally, while converting to and from specific local representations when needed interfacing with the user or other systems.

ZTimestampFormat, working with ZTimezone, is the tool to do these conversions.

ZCurrentTimezone
  value: (ZTimezone id: #'Europe/Brussels')
  during: [ ZTimestampFormat isoTZ useCurrentTimezone format: ZTimestamp now ].

Time Zone Database

ZTimezone adds proper timezone support based on the standard Olsen Timezone database.

The necessary information will be loaded, parsed and cached from a binary file of the zoneinfo database (see also man tzfile). This should work automagically on macOS and Unix, on Windows you have to download the necessary files and specify their location although there is a fallback that downloads the dataset (see #downloadFallbackZoneinfoDataset)

Latest data: tzdata-latest.tar.gz

Github repository: https://github.com/eggert/tz

Formatting & Parsing

Also contains ZTimestampFormat, a 'by example' formatter/parser for DateAndTime, TimeStamp, Date, Time and ZTimestamp.

SNTP

Also contains ZTimestampSNTPClient, a simple SNTP client to check your local clock.

Installation

This is a Pharo Smalltalk project using the Tonel source code format.

In Pharo 7 and up you can use Iceberg to load this project.

You can also load using the following expression:

Metacello new
  baseline: 'ZTimestamp';
  repository: 'github://svenvc/ztimestamp';
  load.

There is also a ZTimestamp-GT package with extensions for GToolkit, which can be loaded with the 'gt' group.

Written and supported by Sven Van Caekenberghe. MIT Licensed.

ztimestamp's People

Contributors

chisandrei avatar draagrenkirneh avatar ducasse avatar erikonbike avatar gcotelli avatar jbrichau avatar svenvc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ztimestamp's Issues

Add documentation about defaultZoneInfoLocation

I am trying to use a project depending on ZTimestamp on windows and I get an error saying that I need to initialize the info location of ZTimeZone myself via #zoneInfoLocation:.

I don't know much about location management on the OSs so I don't really know what I should set. Maybe the comments/error could explain a little to users what they should do or give a link to a Wikipedia explanation.

localPrintString Offset ~= localTimeZone offset

Don't we make the same mistake in #localPrintString as DateAndTime, namely by using the current local offset instead of the (possibly historical) local offset of aZTimestamp?

I assume you're familiar with this issue, but I described it more in depth here and here if it helps.

I can't think of a great way to solve this because IIUC there is not a VM primitive to get the timezone in an abstract way (e.g. ID).

Possible solutions

  • At minimum, a method comment with the limitation might be helpful
  • Is there a reliable cross-platform way to get the timezone ID or similar? Maybe a new primitive is in order. This would pave the way to fix the core system and all libraries.
  • Could the local timezone be optionally set/cached by ZT for the image? That of course would not cover every case, but at least it would give people the option
  • Maybe this method should simply be removed since there's no easy and reliable way to implement it.

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.