Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add timezone getter function in dateTime module [ATLAS-170] #125

Open
wants to merge 20 commits into
base: master
Choose a base branch
from

Conversation

RgnDunes
Copy link
Collaborator

@RgnDunes RgnDunes commented Apr 4, 2024

Description

This PR introduces two getter functions for timezones in date time module along with their UT, E2E and README Docs.

  • getTimezoneList
  • getTimeZoneByCountry

Changes Made

List the main changes made in this pull request.

Title ---
JIRA link https://razorpay.atlassian.net/browse/ATLAS-170
Slack thread (if any) NA
Product spec NA
Tech spec/One-pager NA
Bundle Size Difference NA
Fixes Issue NA

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • This change is a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Is your change backward compatible ?
  • Tested on major browsers (Chrome, Firefox, Safari, IE) ?
  • Tested in a consumer application(s) ?

Additional Notes

Any additional information that would be helpful for the reviewer.

Checklist:

  • Add Jira ID(s) in PR title and in the description?
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • My code is written in TypeScript and follows the coding standards of the project.
  • I have added relevant documentation and updated the README if necessary.
  • My commit messages are clear and follow the project's commit message conventions.
  • Is any external library added?
  • My changes do not introduce any new runtime errors or warnings.
  • All relevant unit tests have been added/updated in my PR for the change.
  • Any Screenshots (mobile & desktop) required for PR? If yes, have you added the respective screenshots ?
  • Any manual dev testing done by you on beta/func environment?
  • Reviewer added (SLA 2 days)

Reviewer Checklist

  • Sufficient QA/Dev-Testing is done with proof (test cases list)
  • Ensure that the change in bundle size falls within the acceptable range.

PR Title Format

Format: <type>: <subject>

Types can be as follows:

  • feat: (new feature for the user, not a new feature for build script)
  • fix: (bug fix for the user, not a fix to a build script)
  • docs: (changes to the documentation)
  • style: (formatting, missing semi colons, etc; no production code change)
  • refactor: (refactoring production code, eg. renaming a variable)
  • test: (adding missing tests, refactoring tests; no production code change)
  • chore: (updating grunt tasks etc; no production code change)

Copy link

changeset-bot bot commented Apr 4, 2024

🦋 Changeset detected

Latest commit: 7b786b6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@razorpay/i18nify-js Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@RgnDunes RgnDunes changed the title feat: add timezon getter function in dateTime module [ATLAS-170] feat: add timezone getter function in dateTime module [ATLAS-170] Apr 5, 2024

This comment has been minimized.

This comment has been minimized.

@rzpcibot
Copy link
Contributor

rzpcibot commented Apr 5, 2024

Bundle Size Report

Files

click to expand/collapse
🟢 No Change 🗑 File Deleted 🆕 New File 📈 Size Increased 👍 Size Reduced
Parsed (kb)
🚦 File Name Base PR Diff %
📈 cjs/index.js 146.22 150.42 $\textcolor{red}{4.2}$ 2.87
📈 esm/index.min.js 52.8 53.96 $\textcolor{red}{1.16}$ 2.2
📈 umd/index.js 166.76 171.25 $\textcolor{red}{4.49}$ 2.69

Generated by 🚫 dangerJS against 7b786b6

This comment has been minimized.

@codecov-commenter
Copy link

codecov-commenter commented Apr 5, 2024

Codecov Report

Attention: Patch coverage is 96.15385% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 95.08%. Comparing base (1047227) to head (97a5116).
Report is 13 commits behind head on master.

Files Patch % Lines
...fy-js/src/modules/dateTime/getTimeZoneByCountry.ts 91.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #125      +/-   ##
==========================================
+ Coverage   95.00%   95.08%   +0.07%     
==========================================
  Files          44       47       +3     
  Lines         501      529      +28     
  Branches      128      130       +2     
==========================================
+ Hits          476      503      +27     
- Misses         24       25       +1     
  Partials        1        1              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.


#### getTimeZoneByCountry(countryCode)

`getTimeZoneByCountry` asynchronously fetches the time zone ⏰ for the capital city 🏙️ of a given country, using its country code 🌍. It's crafted for applications that require displaying or working with time zone-specific information 🕒 across different locations globally 🌎.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not return timezones too ?

* @returns A promise that resolves to the timezone of the capital city for the specified country code.
* @throws Error if the country code is not found in the dynamically imported dataset or if there's an API response error.
*/
const getTimeZoneByCountry = async (countryCode: string): Promise<string> => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's return timezone list too ?

const timezone =
data.metadata_information[countryCode]?.timezone_of_capital;

if (!timezone) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this error be reported in catch block of promise ?
for eg,

getTimeZoneByCountry(IN).then().catch((err) => console.log(err)) ?

{},
);
} catch (err) {
throw new Error(`Error in API response: ${(err as Error).message}`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will it always have message attribute ?

name: string;
}

export interface CountryMetaType {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already defined in geo module, let's add this in common types.

This comment has been minimized.

This comment has been minimized.

Copy link
Contributor

Unit Test Results

0 files  0 suites   0s ⏱️
0 tests 0 ✔️ 0 💤 0 ❌

Results for commit 7b786b6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants