Skip to content

Daily Rotation restructures raw API responses into a clearer, easier-to-use format, improving readability and overall usability for developers without changing the underlying result data.

License

Notifications You must be signed in to change notification settings

LewisRandles/Daily-Rotation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Daily Rotation API Repacker

Accurate sunrise, sunset, and twilight times for any date and time at supported locations.

Badge Badge Badge Badge Badge

Introduction

Daily Rotation is a free, no auth, user-friendly API library that provides accurate sunrise, sunset, and twilight times for any timezone mixed with any supported location worldwide. This project is designed for anyone from photographers and hikers to astronomers and general enthusiasts who wants to plan activities around natural light.


Table of Contents


Downloading

Different Versions

Each release provides two configuations of the project.

  • The bundled, minified format known as "production".
  • The unbundled, unminified format known as "development".

Download Page

https://github.com/LewisRandles/Daily-Rotation/releases


Installing

In your JavaScript file

	// Using the unbundled version needs to be kept with the internal files.
	import dailyRotation from './scripts/dailyRotation_unbundled.js';

	// Using the bundled version is standalone and has no internal files.
	import dailyRotation from './dailyRotation_bundled.js';

Usage

No Parameters

Providing no parameters will result in the default information being set.

await dailyRotation();

First Parameter

The first parameter is providing the desired date. The format is case-insensitive.

First Parameter Type Description
date string Supported date formats include DD-MM-YYYY, YYYY-MM-DD, today, tomorrow and yesterday.
Usage Type Description
date string date is in ISO8601 format.
// Argument object.
await dailyRotation({"date": "2025-01-01"});
// External object.
const apiConfig = {
	"date": "2025-01-01"
}

await dailyRotation(apiConfig);

Second Parameter

The second parameter is providing the desired address within the supported locations. The format is case-insensitive.

Second Parameter Type Description
address string Supports a valid address string from the supported locations list.
Usage Type Description
address string address decides which address is selected.
// Argument object.
await dailyRotation({"date": "2025-01-01", "address": "london, united kingdom"});
// External object.
const apiConfig = {
	"date": "2025-01-01",
	"address": "london, united kingdom"
}

await dailyRotation(apiConfig);

Third Parameter

The third parameter is providing the desired timezone. The format is case-insensitive.

Third Parameter Type Description
timezone string Supported timezone formats include local and any valid IANA timezone.
Usage Type Description
timezone string timezone decides which timezone is selected.
// Argument object.
await dailyRotation({"date": "2025-01-01", "address": "london, united kingdom", "timezone": "Europe/London"});
// External object.
const apiConfig = {
	"date": "2025-01-01",
	"address": "london, united kingdom",
	"timezone": "Europe/London"
}

await dailyRotation(apiConfig);

Supported locations

The current list of supported locations

Supported Location Strings
Tokyo, Japan New York, United States Oslo, Norway Copenhagen, Denmark Seoul, South Korea
Los Angeles, United States London, United Kingdom Paris, France Toronto, Canada Stockholm, Sweden
Helsinki, Finland Berlin, Germany Sydney, Australia Auckland, New Zealand Abchorage, Alaska

Processing

Normalisation

During normalization, raw API fields such as latitude and longitude are combined into "address": { "lat": 40.7127281, "lon": -74.0060152 }, timestamps are split into "datetime", "utc_datetime", and "utc_offset", solar times are grouped under "rotation", administrative fields are simplified into "displayName". Objects provide more reliable and consistent access than arrays while enabling easier manipulation and processing of nested data structures. Nested objects are flattened, redundant metadata and overlapping identifiers are removed, empty or missing fields are normalized, boolean and encoded values are standardized, and all data is organized into a uniform, consistent key-value JSON structure to produce a clean and predictable final result.

Sanitization

During sanitization, instead of leaving object values as null or undefined, missing or empty fields are filled with a placeholder such as "no value" to ensure that every key in the final result has a valid string; this prevents errors in downstream processing, makes the dataset fully predictable, and allows client applications to safely read and display all values without additional null checks.


Customisation

This JSON serves as a configuration layer that lets you enable or disable individual parent and child fields and rename them through altName, giving you full control over which properties appear in the final output. Some values from the raw API return are intentionally omitted because they are considered unnecessary or not useful.

Parent Names

The parents group defines the top-level fields that can be enabled, disabled, or renamed, allowing you to control which main object properties appear in the output.

"parents": {

	"item1": {
		"name": {
			"original": "defaultName",
			"altName": "customName"
		},
		"used": true
	},

	...

}

Child Names

The children group manages the nested fields within those parent objects, giving similar control over which sub-properties are included and how they are labeled.

"children": {
	
	"item1": {
		"name": {
			"original": "defaultName",
			"altName": "customName"
		},
		"used": true,
		"validate": "checkRotation"
	},

	...

}

Demo

Live Demo

Try the hosted demo via GitHub Pages Demo


Authors


Credit


License

MIT License

About

Daily Rotation restructures raw API responses into a clearer, easier-to-use format, improving readability and overall usability for developers without changing the underlying result data.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages