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.

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.